FREEBSD下双网卡负载均衡配置方法
一、加载负载均衡模块(fec:为虚拟接口 em0 em1:为服务器的物理接口)
/sbin/kldload ng_fec
/usr/sbin/ngctl mkpeer fec dummy fec
/usr/sbin/ngctl msg fec0: add_iface ‘”em0″‘
/usr/sbin/ngctl msg fec0: add_iface ‘”em1″‘
/usr/sbin/ngctl msg fec0: set_mode_inet
/sbin/ifconfig fec0 promisc
/sbin/ifconfig fxp0 promisc
/sbin/ifconfig fxp1 promisc
二、给虚拟接口配置IP、增加默认路由
/sbin/ifconfig fec0 inet 192.168.1.2 netmask 255.255.255.0
/sbin/route add default 192.168.1.1
三、注释掉rc.conf中的内容
#defaultrouter=”192.168.1.1″
#ifconfig_em0=”inet 192.168.0.2 netmask 255.255.255.0″
#ifconfig_em1=”inet 192.168.1.2 netmask 255.255.255.0″
按上述命令和顺序操作就可以了。如果想开机自动运行,将一、二中的内容写到一个文件里(例如:/bin/vinet.sh) 中,chmod a+x /bin/vinet.sh。再将/bin/vinet.sh 写入rc.local中即可!该配置在FreeBSD 7.0-RELEASE 中测试通过!
这篇文章目前没有评论