温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

硬件WAF的制作!linux系统制作硬件WAF,实现透明代理,具备断电、故障Bypass功能。

发布时间:2020-07-26 10:03:24 来源:网络 阅读:764 作者:w2sft 栏目:安全技术

硬件bypass的制作过程!

现实需求:WAF类的产品,很多情况下是需要Bypass的,

什么是bypass?为什么要bypass呢?

在现实的应用场景中,很多时候业务系统(网站)是不能中断的,比如银行、电商的网站,如果系统中断、不能访问,后果是十分严重的。

而安全防护系统又不得不使用,这时就要求WAF一定要具备Bypass功能,bypass的意思是指:如果waf本身、或waf所在的服务器、或WAF硬件,由于软件或硬件的原因,死机、断电等各种情况下,都不能影响业务系统正常运转。

而实际的部署方式,经常是反向代理模式(透明代理本质上也差不多),也就是WAF处于业务系统之前,来访数据需先流经WAF,然后再才到达业务系统。在这样一个串联的形态下,如果WAF故障,要保证数据能到达业务系统。业务系统的反馈数据也能正常传达给访问者。

通常实现的方式有两种,一种是采用多机热备,一种是硬件自身bypass。本文讲的,就是如何配置系统,让WAF所在的服务器,具备bypass功能。也可以说,这是硬件WAF的制作过程


系统:Linux CentOS
硬件要求:Bypass网卡

WAF软件:ShareWAF(http://www.sharewaf.com/)


1、准备工作:
ETH1网口连通外网,并给其设置IP;
ETH2,ETH3为一双Bypass网口,为做网桥使用;
ETH3口连接内网web服务器。

2、系统配置,实现透明代理:
关闭centos 7自带防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
安装iptables
yum -y install iptables
yum -y install iptables-services
开启iptables
service iptables start
清除Iptables自带规则
iptables -F
安装ifconfig
yum -y install net-tools.x86_64
安装网桥
yum -y install bridge-utils
设置网桥
/sbin/modprobe bridge
/usr/sbin/brctl addbr br0(设置网桥名为br0)
/sbin/ifup enp4s0 (要加入网桥的网卡,通过ifconfig查看)
/sbin/ifup enp5s0 (要加入网桥的网卡)
注:执行以上两步之前最好将能通的网线插在网口上,否则执行时间会稍长,会显示激活失败。
如果以上步骤报错:
无法创建 NMClient 对象GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Method "GetManagedObjects" with signature "" on interface "org.freedesktop.DBus.ObjectManager" doesn't exist
这时,执行如下命令:
chkconfig NetworkManager off
chkconfig network on
service NetworkManager stop
service network start
/usr/sbin/brctl addif br0 enp4s0
/usr/sbin/brctl addif br0 enp5s0
设置网桥IP (例:192.168.1.73 设置一个在内网网段的IP)
ifconfig br0 192.168.1.73 netmask 255.255.255.0
开启网桥
/sbin/ip link set br0 up
查看
sudo brctl show
关闭
ifconfig br0 down
删除 (删除前先将网桥关闭)
sudo brctl delbr br0
在/etc/sysctl.conf下添加内容
vi /etc/sysctl.conf
将光标移至文字最后一行按o,右键选择粘贴
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.br0.rp_filter = 0
1.按esc  2.输入 :  3.然后输入 wq 回车
执行使生效
sysctl -p
如果报错:
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: 没有那个文件或目录
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: 没有那个文件或目录
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-arptables: 没有那个文件或目录
执行 modprobe br_netfilter
再次执行sysctl -p
添加路由
/sbin/ip -f inet rule add fwmark 1 lookup 100
/sbin/ip -f inet route add local default dev lo table 100
添加规则前,首先查内是否有其他规则
iptables -t 表名 -L
如果有其他规则,将其删除
iptables -t 表名 -D 链名 第几条规则
添加规则
iptables -t nat -A PREROUTING -d 192.168.1.20 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.73:8080
说明:
192.168.1.20 web服务器IP
80 web服务端口
192.168.1.73 网桥IP
8080 ShareWAF端口
保存规则
service iptables save
以上,系统透明模式需要的设置已完成。为实现断电或异常时Bypass功能,还需向Bypass网卡或硬件厂家咨询、索取其Bypass网卡相关程序、资料,如:“喂狗程序”、脚本等。

3、安装NodeJS:
yum -y install wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak 
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache 
wget https://nodejs.org/dist/v8.11.1/node-v8.11.1-linux-x64.tar.xz --no-check-certificate
tar -xvf node-v8.11.1-linux-x64.tar.xz
mv node-v8.11.1-linux-x64 node-v8.11.1
ln -s /root/node-v8.11.1/bin/node /usr/local/bin/node
ln -s /root/node-v8.11.1/bin/npm /usr/local/bin/npm

4、安装ShareWAF
获取ShareWAF程序包后,在其目录下执行:
npm init
如在安装过程中Express报错,运行:npm config set strict-ssl false
如在安装过程中Sqlite3报错,运行:npm install sqlite3 --unsafe-perm


完成!此时,这台具有bypass网卡的服务器,即成为了一台硬件WAF!


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI