Chinaunix首页 | 论坛 | 博客
  • 博客访问: 161145
  • 博文数量: 22
  • 博客积分: 2140
  • 博客等级: 大尉
  • 技术积分: 242
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-31 17:40
文章分类

全部博文(22)

文章存档

2014年(1)

2010年(1)

2009年(2)

2008年(18)

分类: BSD

2008-04-18 18:03:44

CU上参考了网友在5.x、6.3下双网卡绑定的文档,于是自己在7.0下做了次实验,结果成功通过。
自己做了些修改,留个笔记!

具体实现的方法可以通过动态模块加载静态编译内核的方式来实现


一、通过动态模块加载模式实现。

1. 编译和加载netgraph.ko、ng_fecko、ng_socket.ko模块
a. 编译

#cd /usr/src/sys/modules/netgraph/
#cd netgraph/ && make && make install clean
#cd ../fec && make && make install clean
#cd ../socket && make && make install clean


b. 加载

#cat >> /boot/loader.conf << EOF
ng_ether_load="YES"
ng_fec_load="YES"
ng_socket_load="YES"
EOF

c. 修改rc.conf

#sed -i.bak -e 's/^\(defaultrouter\)/#\1/' -e 's/^\(ifconfig_\)/#\1/' /etc/rc.conf


2. 编辑启动脚本

# cat > /etc/bonding << EOF
#!/bin/sh
MYIP=xxx.xxx.xxx.xxx
GW=xxx.xxx.xxx.xxx
NIC1=bge0
NIC2=bge1

/usr/sbin/ngctl mkpeer fec dummy fec
/usr/sbin/ngctl msg fec0: add_iface '"'\${NIC1}'"'
/usr/sbin/ngctl msg fec0: add_iface '"'\${NIC2}'"'
/usr/sbin/ngctl msg fec0: set_mode_inet
/sbin/ifconfig fec0 promisc
/sbin/ifconfig \${NIC1} promisc
/sbin/ifconfig \${NIC2} promisc
/sbin/ifconfig fec0 inet \${MYIP} netmask 0xfffffe00
/sbin/ifconfig fec0 up
/sbin/route add default \${GW}
EOF


# chmod 400 /etc/bonding
# echo "sh /etc/bonding" >> /etc/rc.local

 

二、通过静态编译内核方式实现

1. 将参数加入内核配置文档
# NIC bonding
options     NETGRAPH
options     NETGRAPH_FEC
options     NETGRAPH_SOCKET
重新编译内核

2. 配置/etc/rc.conf
添加和修改如下选项,如原先有配置过IP项,要先注释掉。
defaultrouter="xx.xx.xx.1"
#ifconfig_bge0="inet 192.168.1.63  netmask 255.255.255.0"
fec_interfaces="fec0"
fecconfig_fec0="bge0 bge1"  # Examples typically for two NICs
ifconfig_fec0="inet
192.168.1.63 netmask 0xfffffe00"

二、重启系统
# reboot

三、核对配置后的状态
# ifconfig
bge0: flags=28943 metric 0 mtu 1500
        options=9b
        ether 00:13:21:c8:54:6b
        media: Ethernet autoselect (1000baseTX )
        status: active
bge1: flags=28943 metric 0 mtu 1500
        options=9b
        ether 00:13:21:c8:54:6b
        media: Ethernet autoselect (1000baseTX )
        status: active
lo0: flags=8049 metric 0 mtu 16384
        inet 127.0.0.1 netmask 0xff000000
fec0: flags=28943 metric 0 mtu 1500
        ether 00:13:21:c8:54:6b
        inet xxx.xxx.xxx.xxx netmask 0xfffffe00 broadcast xxx.xxx.xxx.xxx
        media: Ethernet none
        status: active

参考文献:
%3D1#pid8240919

阅读(2683) | 评论(0) | 转发(0) |
0

上一篇:vmstat用法

下一篇:Netgraph静态编译的参数

给主人留下些什么吧!~~