参考:http://www.countersiege.com/doc/pfsync-carp/
参考:pfsync 及 carp 手册
实验环境:
VMWare 5.5,虚拟三台BSD,两台OpenBSD,一台FreeBSD.每台OpenBSD均有三块网卡.
虚拟机1:
名称:OpenBSD(GZ)
网卡pcn0:192.168.0.110/24 (接外网 vmnet0 桥接 192.168.0.0/24)
网卡pcn1:192.168.20.110/24 (接内网 vmnet2 NAT 192.168.20.0/24)
网卡pcn2:192.168.30.110/24 (pfsync vmnet3 NAT 192.168.30.0/24)
网关:192.168.0.254
虚拟机2:
名称:OpenBSD(PY)
网卡pcn0:192.168.0.120/24 (接外网 vmnet0 桥接 192.168.0.0/24)
网卡pcn1:192.168.20.120/24 (接内网 vmnet2 NAT 192.168.20.0/24)
网卡pcn2:192.168.30.120/24 (pfsync vmnet3 NAT 192.168.30.0/24)
网关:192.168.0.254
虚拟机3:
名称:FreeBSD
网卡lnc0:192.168.20.10/24 (接内网 vmnet2 NAT 192.168.20.0/24)
网关:192.168.20.200
[attach]122409[/attach]
设置:
1./etc/pf.conf(两台OpenBSD使用相同的规则),下面的规则非常简单,只用于测试.
ext_if = "pcn0"
int_if = "pcn1"
sync_if = "pcn2"
loop_if = "lo0"
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
2.在OpenBSD(GZ)和OpenBSD(PY)中,分别增加下面文件.
# vi /etc/hostname.carp0
vhid 1 pass foo 192.168.0.200 255.255.255.0
# vi /etc/hostname.carp1
vhid 2 pass bar 192.168.20.200 255.255.255.0
# vi /etc/hostname.pfsync0
syncpeer 192.168.30.200 syncdev pcn2
# vi /etc/rc.conf.local
pf=YES
3.设置FreeBSD
# vi /etc/rc.conf
defaultrouter="192.168.20.200"
ifconfig_lnc0="inet 192.168.20.10 netmask 255.255.255.0"
# vi /etc/resolv.conf
nameserver 202.96.128.68
nameserver 202.96.134.133
4.设置完毕之后,重启三台虚拟机.
5.简单测试:
在FreeBSD虚拟机中,ping一个Internet上的真实IP,随便关闭那一台OpenBSD都可以.:em02::em02:
附ifconfig
1.OpenBSD(GZ)
lo0: flags=8049 mtu 33224
groups: lo
inet 127.0.0.1 netmask 0xff000000
pcn0: flags=8b43 mtu 1500
lladdr 00:0c:29:fe:67:4b
groups: egress
media: Ethernet autoselect (autoselect)
inet 192.168.0.110 netmask 0xffffff00 broadcast 192.168.0.255
pcn1: flags=8b43 mtu 1500
lladdr 00:0c:29:fe:67:55
media: Ethernet autoselect (autoselect)
inet 192.168.20.110 netmask 0xffffff00 broadcast 192.168.20.255
pcn2: flags=8843 mtu 1500
lladdr 00:0c:29:fe:67:5f
media: Ethernet autoselect (autoselect)
inet 192.168.30.110 netmask 0xffffff00 broadcast 192.168.30.255
pflog0: flags=141 mtu 33224
pfsync0: flags=0 mtu 1348
pfsync: syncdev: pcn2 syncpeer: 192.168.30.200 maxupd: 128
enc0: flags=0 mtu 1536
carp0: flags=8843 mtu 1500
carp: BACKUP carpdev pcn0 vhid 1 advbase 1 advskew 0
groups: carp
inet 192.168.0.200 netmask 0xffffff00 broadcast 255.255.255.0
carp1: flags=8843 mtu 1500
carp: BACKUP carpdev pcn1 vhid 2 advbase 1 advskew 0
groups: carp
inet 192.168.20.200 netmask 0xffffff00 broadcast 255.255.255.0
2.OpenBSD(PY)
lo0: flags=8049 mtu 33224
groups: lo
inet 127.0.0.1 netmask 0xff000000
pcn0: flags=8b43 mtu 1500
lladdr 00:0c:29:cc:f5:37
groups: egress
media: Ethernet autoselect (autoselect)
inet 192.168.0.120 netmask 0xffffff00 broadcast 192.168.0.255
pcn1: flags=8b43 mtu 1500
lladdr 00:0c:29:cc:f5:41
media: Ethernet autoselect (autoselect)
inet 192.168.20.120 netmask 0xffffff00 broadcast 192.168.20.255
pcn2: flags=8843 mtu 1500
lladdr 00:0c:29:cc:f5:4b
media: Ethernet autoselect (autoselect)
inet 192.168.30.120 netmask 0xffffff00 broadcast 192.168.30.255
pflog0: flags=141 mtu 33224
pfsync0: flags=0 mtu 1348
pfsync: syncdev: pcn2 syncpeer: 192.168.30.200 maxupd: 128
enc0: flags=0 mtu 1536
carp0: flags=8843 mtu 1500
carp: MASTER carpdev pcn0 vhid 1 advbase 1 advskew 0
groups: carp
inet 192.168.0.200 netmask 0xffffff00 broadcast 255.255.255.0
carp1: flags=8843 mtu 1500
carp: MASTER carpdev pcn1 vhid 2 advbase 1 advskew 0
groups: carp
inet 192.168.20.200 netmask 0xffffff00 broadcast 255.255.255.0
3.FreeBSD
# ifconfig
lnc0: flags=108843 mtu 1500
inet 192.168.20.10 netmask 0xffffff00 broadcast 192.168.20.255
inet6 fe80::20c:29ff:fe1d:bbda%lnc0 prefixlen 64 scopeid 0x1
ether 00:0c:29:1d:bb:da
自由广告区 |
分类导航 |
邮件新闻资讯: IT业界 | 邮件服务器 | 邮件趣闻 | 移动电邮 电子邮箱 | 反垃圾邮件|邮件客户端|网络安全 行业数据 | 邮件人物 | 网站公告 | 行业法规 网络技术: 邮件原理 | 网络协议 | 网络管理 | 传输介质 线路接入 | 路由接口 | 邮件存储 | 华为3Com CISCO技术 | 网络与服务器硬件 操作系统: Windows 9X | Linux&Uinx | Windows NT Windows Vista | FreeBSD | 其它操作系统 邮件服务器: 程序与开发 | Exchange | Qmail | Postfix Sendmail | MDaemon | Domino | Foxmail KerioMail | JavaMail | Winwebmail |James Merak&VisNetic | CMailServer | WinMail 金笛邮件系统 | 其它 | 反垃圾邮件: 综述| 客户端反垃圾邮件|服务器端反垃圾邮件 邮件客户端软件: Outlook | Foxmail | DreamMail| KooMail The bat | 雷鸟 | Eudora |Becky! |Pegasus IncrediMail |其它 电子邮箱: 个人邮箱 | 企业邮箱 |Gmail 移动电子邮件:服务器 | 客户端 | 技术前沿 邮件网络安全: 软件漏洞 | 安全知识 | 病毒公告 |防火墙 攻防技术 | 病毒查杀| ISA | 数字签名 邮件营销: Email营销 | 网络营销 | 营销技巧 |营销案例 邮件人才:招聘 | 职场 | 培训 | 指南 | 职场 解决方案: 邮件系统|反垃圾邮件 |安全 |移动电邮 |招标 产品评测: 邮件系统 |反垃圾邮件 |邮箱 |安全 |客户端 |