ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux 5/6 配置网卡桥接[bond]

Linux 5/6 配置网卡桥接[bond]

原创 Linux操作系统 作者:xingxintian 时间:2014-08-21 16:33:07 0 删除 编辑
测试过的系统环境:Centos Linux 5.10/6.5,
所以CentOS 5.x 或者 CentOS 6.x的用户可以放心配置使用,
对于CentOS 7.x还没有正式测试过,因为出现了另一种配置方法,这里不做记录。

1、新建bond文件

点击(此处)折叠或打开

  1. [root@xxxx ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
  2. DEVICE=bond0
  3. BOOTPROTO=none
  4. IPADDR=172.16.3.120
  5. NETMASK=255.255.255.0
  6. ONBOOT=yes
  7. GATEWAY=172.16.3.254
  8. USERCTL=no
2、配置网卡0文件

点击(此处)折叠或打开

  1. [root@xxxx ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
  2. DEVICE=eth0
  3. BOOTPROTO=none
  4. ONBOOT=yes
  5. MASTER=bond0
  6. slave=yes
  7. USERCTL=no
3、配置网卡1文件

点击(此处)折叠或打开

  1. [root@xxxx ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
  2. DEVICE=eth1
  3. BOOTPROTO=none
  4. ONBOOT=yes
  5. USERCTL=no
  6. MASTER=bond0
  7. slave=yes
4、编辑/etc/modprobe.conf文件, 增加13-14行内容

点击(此处)折叠或打开

  1. [root@xxxx ~]# cat /etc/modprobe.conf
  2. alias scsi_hostadapter shpchp
  3. alias eth0 bnx2
  4. alias eth1 bnx2
  5. alias scsi_hostadapter1 megaraid_sas
  6. alias scsi_hostadapter2 ata_piix
  7. alias scsi_hostadapter3 usb-storage
  8. alias net-pf-10 off
  9. alias ipv6 off
  10. options ipv6 disable=1
  11. alias usb0 cdc_ether

  12. alias bond0 bonding
  13. options bond0 miimon=100 mode=1
4、在启动项加入 ifenslave bond0 eth0 eth1 ,第10行
点击(此处)折叠或打开
  1. [root@xxxx ~]# cat /etc/rc.d/rc.local
  2. #!/bin/sh
  3. #
  4. # This script will be executed *after* all the other init scripts.
  5. # You can put your own initialization stuff in here if you don\'t
  6. # want to do the full Sys V style init stuff.

  7. touch /var/lock/subsys/local

  8. ifenslave bond0 eth0 eth1

  9. su oracle -lc /dbbak/scripts/startup.sh
5、重启服务器完成



6、服务器启动后执行ifconfig检查配置结果

点击(此处)折叠或打开

  1. [root@xxxx ~]# ifconfig
  2. bond0 Link encap:Ethernet HWaddr E4:1F:13:65:1A:C8
  3. inet addr:172.16.3.120 Bcast:172.16.3.255 Mask:255.255.255.0
  4. UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
  5. RX packets:4075442 errors:0 dropped:2736870 overruns:0 frame:0
  6. TX packets:1760516 errors:0 dropped:0 overruns:0 carrier:0
  7. collisions:0 txqueuelen:0
  8. RX bytes:327142540 (311.9 MiB) TX bytes:2302923391 (2.1 GiB)

  9. eth0 Link encap:Ethernet HWaddr E4:1F:13:65:1A:C8
  10. UP BROADCAST SLAVE MULTICAST MTU:1500 Metric:1
  11. RX packets:54996 errors:0 dropped:26 overruns:0 frame:0
  12. TX packets:2497 errors:0 dropped:0 overruns:0 carrier:0
  13. collisions:0 txqueuelen:1000
  14. RX bytes:4838283 (4.6 MiB) TX bytes:576512 (563.0 KiB)

  15. eth1 Link encap:Ethernet HWaddr E4:1F:13:65:1A:C8
  16. UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
  17. RX packets:4020446 errors:0 dropped:92143 overruns:0 frame:0
  18. TX packets:1758019 errors:0 dropped:0 overruns:0 carrier:0
  19. collisions:0 txqueuelen:1000
  20. RX bytes:322304257 (307.3 MiB) TX bytes:2302346879 (2.1 GiB)
bond0、eth0、eth1的mac地址相同,只有bond0有IP地址。
至此,配置成功。





来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28538954/viewspace-1255425/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-03-01

  • 博文量
    21
  • 访问量
    77524