资料分类
硬件内存 |主板 |CPU |硬盘 |显卡 |网卡 |声卡 |光驱 | 笔记本专区 | 刻录机| 鼠标| 键盘 |病毒专题

办公:打印机|扫描仪|复印机 网络ADSL|局域网| 防火墙 | 路由器 | 无线网络 | 系统winxp win2003 winvisa 服务器

常用维修软件: GHOST | DM | PC3000 | NDD | PQMagic | 效率源 | 还原精灵 电子基础: 电子元件 | 工具应用 | 电路基础
您现在的位置: 龙腾电脑维修网 >> 技术资料 >> 硬件专栏 >> 网卡 >> 文章正文

RH Linux9中实现双网卡绑定

RH Linux9中实现双网卡绑定


本次实验环境:

RedHat Linux 9.0
Kernel: 2.4.20-8
eth0/eth1

        我的Linux上两块网卡分别配了公有地址:eth0-xxx.xxx.180.59和eth1-10.4.2.3,这台机器是一台没有显示器和键盘鼠标的主机,所以我首先选择远程登录的那个接口为主(就是说即使绑定不成功我也希望还能远程登录成功)。整个操作如下:

  1. 编写bond0接口配置文件:
    #cd /etc/sysconfig/network-scripts/
    #ls ifcfg-*
    ifcfg-eth0  ifcfg-eth1  ifcfg-lo
    #cp ifcfg-eth0 ifcfg-bond0
    #
  2. 编辑/etc/sysconfig/network-scripts/ifcfg-bond0,其DEVICE=eth0改为DEVICE=bond0
  3. 编辑/etc/modules.conf,在文件末尾加入以下内容:
    alias  bond0 bonding
    options bond0  miimon=100  mode=1
  4. 编辑/etc/rc.d/rc.local,在文件末尾加上以下内容:(需要注意的是xxx为你实际地址的部分)
    ifenslave bond0 eth0 eth1
    route add -net xxx.xxx.180.0 netmask 255.255.255.0 bond0
  5. 重新启动网卡:
    #/etc/rc.d/init.d/network restart
    Shutting down interface eth0:  [  OK  ]
    Shutting down interface eth1:  [  OK ]
    Shutting down loopback interface:  [ OK ]
    Setting network parameters:  [ OK ]
    Bringing up loopback interface:  [  OK  ]
    Bringing up interface bond0:  [  OK  ]
    Bringing up interface eth0:  [  OK  ]
    Bringing up interface eth1:  [  OK  ]
    #
  6. 检查是否成功:
    #netstat -r
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    xxx.xxx.180.0     *               255.255.255.0   U         0 0          0 bond0
    xxx.xxx.180.0     *               255.255.255.0   U         0 0          0 eth0
    xxx.xxx.180.0     *               255.255.255.0   U         0 0          0 eth1
    127.0.0.0       *               255.0.0.0       U         0 0          0 lo
    #


绑定成功后用ifconfig查看接口信息,显示如下:(其中inet6的项是IPv6的信息,这台机器支持IPv6)
# ifconfig
bond0     Link encap:Ethernet  HWaddr 00:01:02:87:B2:65 
          inet addr:xxx.xxx.180.89  Bcast:xxx.xxx.180.255  Mask:255.255.255.0
          inet6 addr: fe80::200:ff:fe00:0/ Scope:Link
          inet6 addr: 2001:250:f004:f001:201:2ff:fe87:b265/ Scope:Global
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:3137 errors:0 dropped:0 overruns:0 frame:0
          TX packets:801 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:336924 (329.0 Kb)  TX bytes:91875 (89.7 Kb)

eth0      Link encap:Ethernet  HWaddr 00:01:02:87:B2:65 
          inet addr:xxx.xxx.180.89  Bcast:xxx.xxx.180.255  Mask:255.255.255.0
          inet6 addr: fe80::201:2ff:fe87:b265/ Scope:Link
          UP BROADCAST NOARP SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:2260 errors:0 dropped:0 overruns:0 frame:0
          TX packets: errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:217928 (212.8 Kb)  TX bytes:82889 (80.9 Kb)
          Interrupt:10 Base address:0xdc00

eth1      Link encap:Ethernet  HWaddr 00:01:02:87:B2:65  Media:unknown(auto)
          inet addr:xxx.xxx.180.89  Bcast:xxx.xxx.180.255  Mask:255.255.255.0
          inet6 addr: fe80::201:2ff:fe87:b265/ Scope:Link
          UP BROADCAST DEBUG NOTRAILERS RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:877 errors:0 dropped:0 overruns:0 frame:0
          TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:118996 (116.2 Kb)  TX bytes:9324 (9.1 Kb)
          Interrupt:11 Base address:0x5e00

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:136  Metric:1
          RX packets:22 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1732 (1.6 Kb)  TX bytes:1732 (1.6 Kb)

使用cat命令查看/etc/sysconfig/network-scripts/ifcfg-eth1文件,结果如下:
# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.4.2.3
NETMASK=255.255.255.192
GATEWAY=10.4.2.1
NETWORK=10.4.2.0
BROADCAST=10.4.2.255
#

可以看出eth1接口的配置信息并没有改变,但是已经无效。

  • 上一篇文章:

  • 下一篇文章:

  • 如果您发现该文章有错误,请通知管理员,谢谢!
    作者:佚名
    点击数:
    更新时间:2006-11-5 19:10:55
    我要发表评论
    本站论坛
    返回文章首页
    我要发表文章
    评论内容只代表网友观点,与本站立场无关!

    公司简介 - 联系方法 - 合作伙伴 - RSS订阅 - 意见反馈 - Dragon computer(龙腾电脑英文站) - 版权声明
    @ 2006-2008龙腾电脑 版权所有. ALL RIGHTS RESERVED. 浙ICP备05046531号
    友情连接QQ:42738612 本站QQ群:28651784 26926005