OpenBSD高性能防火墙系统配置攻略
三、冗余功能配置
要实现故障冗余功能,至少需要两台机器, 如果客户机器比较多, 可以增加防火墙的机器数量。下面笔者以两台机器为例来做实验,如图3 所示,fxp0网卡是公网地址,接外网出口,fxpl是rfc1918规定的私有地址,接内网。fxp2是私有地址, 用来连接两台机器。
图 2 OpenBSD防火墙的冗余功能配置
在这里要实现的功能为两块fxpl网卡虚拟出一块虚拟网卡做内网的网关, 下面机器网关均设置为该虚拟的网卡地址,当其中一台机器出故障之后,另外一台机器马上代替工作。假设openbsd 1是主防火墙,。
openbsd 1配置如下
要实现故障冗余功能,至少需要两台机器, 如果客户机器比较多, 可以增加防火墙的机器数量。下面笔者以两台机器为例来做实验,如图3 所示,fxp0网卡是公网地址,接外网出口,fxpl是rfc1918规定的私有地址,接内网。fxp2是私有地址, 用来连接两台机器。

图 2 OpenBSD防火墙的冗余功能配置
在这里要实现的功能为两块fxpl网卡虚拟出一块虚拟网卡做内网的网关, 下面机器网关均设置为该虚拟的网卡地址,当其中一台机器出故障之后,另外一台机器马上代替工作。假设openbsd 1是主防火墙,。
openbsd 1配置如下
openbsd 2配置如下:/etc/hostname.fxp0:
inet 10.0.0.254 255.255.255.0 none
/etc/hostname.fxp1:
inet 192.168.0.254 255.255.255.0 none
/etc/hostname.fxp2:
inet 192.168.254.254 255.255.255.0 none
/etc/hostname.carp0:
inet 10.0.0.1 255.255.255.0 10.0.0.255 vhid 1 pass foo
/etc/hostname.carp1:
inet 192.168.0.1 255.255.255.0 192.168.0.255 vhid 2 pass bar
/etc/hostname.pfsync0:
up syncif fxp2
/etc/hostname.carp0:
inet 10.0.0.1 255.255.255.0 10.0.0.255 vhid 1 advskew 100 pass foo
/etc/hostname.carp1:
inet 192.168.0.1 255.255.255.0 192.168.0.255 vhid 2 advskew 100 pass bar
因为要在两个网卡之间路由数据包, 所以需要在/etc/sysctl.conf里加入如下代码:
net.inet.ip.forwarding=1
net.inet6.ip6.forwarding=1
net.inet.carp.preempt=1
建立规则文件:
sudo pfctl -ef /etc/pf.conf
文件内容:
#######################
# macro definitions
ext_if = " fxp0"
int_if = " fxp1"
localnet = $int_if:network
nat on $ext_if from $int_if:network to any -> $ext_if
pass quick on { $sync_if } proto pfsync
pass on { $ext_if $int_if } proto carp keep state
pass in quick all keep state
pass out quick all keep state
########################
# macro definitions
0
相关文章