在honeyproject项目中的hoenywall里面有一个透明的网关,后来我们叫做蜜网网关,然后这个网关上面配置了iptables防火墙,这样我们也叫做透明防火墙。透明顾名思义是看不见,没有存在感。所以,透明网关与透明防火墙是部署在网络上的安全设备,而这两种安全设备是其他网络用户不能感知其存在感的。网络上的设备要做到透明的功能,可以使用网桥技术。linux系统上搭建网桥,把网桥配置成透明模式。网桥,作为一种网络桥梁,联通网络的两端,支持两端的网络通讯。下面是配置透明网关、透明防火墙的过程。事实,一个有透明网桥功能的linux操作系统设备可以看做一个透明网关,然后,在该linux系统上做网络流量监控工作,如:网路抓包、部署防火墙、入侵检测等等。
liang@liang-PC:~$ brctl -h
brctl addbr br0
停止生成树协议:
brctl stp br0 off
brctl addif br0 eth0
brctl addif br0 eth1
配置两块网卡不使用IP地址:
ifconfig eth0 down
ifconfig eth1 down
ifconfig eth0 0.0.0.0 up
ifconfig eth1 0.0.0.0 up
因为两块网卡作为网桥的两个接口,这两个接口分别连接两个不同的网络,支持两个网络的正常通信,不再需要IP,只需要传递网络流量即可。
ifconfig br0 10.0.3.129 up (注意这样的网桥并不是透明网桥,因为使用的真实的IP地址,其他网络设备可见)
透明网桥的IP位置:
ifconfig br0 0.0.0.0 up (这样网桥就没有IP地址,其他设备就无法感知网桥的存在。到此,透明网桥基本配置完成,透明网关的属性自然有了,但是透明防火墙的功能没有完全支持,继续往下。)
liang@liang-PC:~$ iptables -h
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
同样,bridge-nf-call-arptables、bridge-nf-call-ip6tables。到这里,透明防火墙也配置完毕,此时经过网桥的流量就受到防火墙的控制。
1、安装网桥
1.1ubuntu安装网桥命令:
sudo apt-get install bridge-utils1.2centos安装网桥命令:
yum install bridge-utils1.3源码安装:
去bridge-utils官网下载源码安装,安装过程参照官网即可。2、配置网桥
2.1网桥的使用
终端输入命令:liang@liang-PC:~$ brctl -h
打印网桥的使用帮助:
Usage: brctl [commands]
commands:
addbr <bridge> add bridge
delbr <bridge> delete bridge
addif <bridge> <device> add interface to bridge
delif <bridge> <device> delete interface from bridge
hairpin <bridge> <port> {on|off} turn hairpin on/off
setageing <bridge> <time> set ageing time
setbridgeprio <bridge> <prio> set bridge priority
setfd <bridge> <time> set bridge forward delay
sethello <bridge> <time> set hello time
setmaxage <bridge> <time> set max message age
setpathcost <bridge> <port> <cost> set path cost
setportprio <bridge> <port> <prio> set port priority
show [ <bridge> ] show a list of bridges
showmacs <bridge> show a list of mac addrs
showstp <bridge> show bridge stp info
stp <bridge> {on|off} turn stp on/off
2.2创建网桥
添加一个网桥:brctl addbr br0
停止生成树协议:
brctl stp br0 off
2.3添加网卡设备到网桥
添加两块网卡到网桥:brctl addif br0 eth0
brctl addif br0 eth1
配置两块网卡不使用IP地址:
ifconfig eth0 down
ifconfig eth1 down
ifconfig eth0 0.0.0.0 up
ifconfig eth1 0.0.0.0 up
因为两块网卡作为网桥的两个接口,这两个接口分别连接两个不同的网络,支持两个网络的正常通信,不再需要IP,只需要传递网络流量即可。
3、配置透明网桥
3.1透明网桥的ip设置
网桥的IP设置:ifconfig br0 10.0.3.129 up (注意这样的网桥并不是透明网桥,因为使用的真实的IP地址,其他网络设备可见)
透明网桥的IP位置:
ifconfig br0 0.0.0.0 up (这样网桥就没有IP地址,其他设备就无法感知网桥的存在。到此,透明网桥基本配置完成,透明网关的属性自然有了,但是透明防火墙的功能没有完全支持,继续往下。)
4、配置防火墙
4.1防火墙的使用
终端输入命令:liang@liang-PC:~$ iptables -h
打印iptabels防火墙的使用帮助:
iptables v1.4.21
Usage: iptables -[ACD] chain rule-specification [options]
iptables -I chain [rulenum] rule-specification [options]
iptables -R chain rulenum rule-specification [options]
iptables -D chain rulenum [options]
iptables -[LS] [chain [rulenum]] [options]
iptables -[FZ] [chain] [options]
iptables -[NX] chain
iptables -E old-chain-name new-chain-name
iptables -P chain target [options]
iptables -h (print this help information)
Commands:
Either long or short options are allowed.
--append -A chain Append to chain
--check -C chain Check for the existence of a rule
--delete -D chain Delete matching rule from chain
--delete -D chain rulenum
Delete rule rulenum (1 = first) from chain
--insert -I chain [rulenum]
Insert in chain as rulenum (default 1=first)
--replace -R chain rulenum
Replace rule rulenum (1 = first) in chain
--list -L [chain [rulenum]]
List the rules in a chain or all chains
--list-rules -S [chain [rulenum]]
Print the rules in a chain or all chains
--flush -F [chain] Delete all rules in chain or all chains
--zero -Z [chain [rulenum]]
Zero counters in chain or all chains
--new -N chain Create a new user-defined chain
--delete-chain
-X [chain] Delete a user-defined chain
--policy -P chain target
Change policy on chain to target
--rename-chain
-E old-chain new-chain
Change chain name, (moving any references)
Options:
--ipv4 -4 Nothing (line is ignored by ip6tables-restore)
--ipv6 -6 Error (line is ignored by iptables-restore)
[!] --protocol -p proto protocol: by number or name, eg. `tcp'
[!] --source -s address[/mask][...]
source specification
[!] --destination -d address[/mask][...]
destination specification
[!] --in-interface -i input name[+]
network interface name ([+] for wildcard)
--jump -j target
target for rule (may load target extension)
--goto -g chain
jump to chain with no return
--match -m match
extended match (may load extension)
--numeric -n numeric output of addresses and ports
[!] --out-interface -o output name[+]
network interface name ([+] for wildcard)
--table -t table table to manipulate (default: `filter')
--verbose -v verbose mode
--wait -w wait for the xtables lock
--line-numbers print line numbers when listing
--exact -x expand numbers (display exact values)
[!] --fragment -f match second or further fragments only
--modprobe=<command> try to insert modules using this command
--set-counters PKTS BYTES set the counter during insert/append
[!] --version -V print package version.
5、配置透明防火墙
5.1配置透明防火墙
配置网桥后发现经过网桥的流量并没有受到iptables防火的控制,原因是系统没有打开网桥支持防火墙的配置:echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
同样,bridge-nf-call-arptables、bridge-nf-call-ip6tables。到这里,透明防火墙也配置完毕,此时经过网桥的流量就受到防火墙的控制。