温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

linux下如何实现双网卡绑定

发布时间:2021-11-05 09:11:16 来源:亿速云 阅读:161 作者:柒染 栏目:建站服务器

linux下如何实现双网卡绑定,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

点击(此处)折叠或打开

  1. Linux下的双网卡绑定

  2.     将eth0,eth2绑定为bond0 ,节点内部通信用,使用192.168.1.0网段。

  3.     将eth3,eth4绑定为bond1 ,对外服务,使用10.12*.*.0网段。注意将*替换成实际IP地址。

  4. 确定可用的网卡

  5. ethtool eth0

  6. ifup eth0

  7. ifdown eth0


  8.       

  9.     操作系统版本为:Red Hat Enterprise Linux AS release 4 (Nahant Update 7)

  10.       

  11.     <1>

  12.     将eth0,eth2绑定为bond0

  13.       

  14.     vi /etc/sysconfig/network-scripts/ifcfg-bond0

  15.       

  16.     DEVICE=bond0

  17.     BOOTPROTO=none

  18.     ONBOOT=yes

  19.     TYPE=Ethernet

  20.     USERCTL=no

  21.     IPADDR=192.168.1.2

  22.     NETMASK=255.255.255.0

  23.     NETWORK=192.168.1.0

  24.     BROADCAST=192.168.1.255

  25.       

  26.       

  27.     vi /etc/sysconfig/network-scripts/ifcfg-eth0

  28.     DEVICE=eth0

  29.     BOOTPROTO=none

  30.     ONBOOT=yes

  31.     USERCTL=no

  32.     MASTER=bond0

  33.     SLAVE=yes

  34.     注:不要有实际网卡的MAC地址。

  35.       

  36.     vi /etc/sysconfig/network-scripts/ifcfg-eth2

  37.     DEVICE=eth2

  38.     BOOTPROTO=none

  39.     ONBOOT=yes

  40.     USERCTL=no

  41.     MASTER=bond0

  42.     SLAVE=yes

  43.       

  44.       

  45.     <2>

  46.     将eth3,eth4绑定为bond1

  47.       

  48.     vi /etc/sysconfig/network-scripts/ifcfg-bond1

  49.       

  50.     DEVICE=bond1

  51.     BOOTPROTO=none

  52.     ONBOOT=yes

  53.     TYPE=Ethernet

  54.     USERCTL=no

  55.     IPADDR=10.12*.*.61

  56.     NETMASK=255.255.255.0

  57.     NETWORK=10.12*.*.0

  58.     BROADCAST=10.12*.*.255

  59.     GATEWAY=10.12*.*.254

  60.       

  61.     vi /etc/sysconfig/network-scripts/ifcfg-eth3

  62.     DEVICE=eth3

  63.     BOOTPROTO=none

  64.     ONBOOT=yes

  65.     USERCTL=no

  66.     MASTER=bond1

  67.     SLAVE=yes

  68.       

  69.       

  70.     vi /etc/sysconfig/network-scripts/ifcfg-eth4

  71.     DEVICE=eth4

  72.     BOOTPROTO=none

  73.     ONBOOT=yes

  74.     USERCTL=no

  75.     MASTER=bond1

  76.     SLAVE=yes

  77.       

  78.       

  79.     <3>

  80.       

  81.     添加内核模块:

  82.       

  83.     vi /etc/modprobe.conf

  84.     添加

  85.     # BONDING

  86.     install bond0 /sbin/modprobe bonding -o bond0 mode=1 miimon=100

  87.     install bond1 /sbin/modprobe --ignore-install bonding -o bond1 mode=1 miimon=100

  88.       

  89.     note:

  90.     mode=0 : load balancing (round-robin)

  91.     mode=1 : fault-tolerance (active-backup)

  92.       

  93.       

  94.     加入启动项

  95.     vi /etc/rc.d/rc.local

  96.     ifenslave bond0 eth0 eth2

  97.     ifenslave bond1 eth3 eth4

  98.       

  99.     启动网卡

  100.     ifconfig bond0 192.168.1.2 up

  101.     ifenslave bond0 eth0 eth2

  102.       

  103.     ifconfig bond1 10.12*.*.61 up

  104.     ifenslave bond1 eth3 eth4

  105.       

  106.       

  107.     重启网络服务或系统:

  108.     service network restart

  109.       

  110.       

  111.     查看绑定网卡工作状况:

  112.     cat /proc/net/bonding/bond0

  113.     cat /proc/net/bonding/bond1

  114.       

  115.       

  116.     ************************************************************

  117.       

  118.     linux4.7上,使用如下方式配置,当设置两个或以上bond时,bond网卡的工作模式会有问题,并且第二个bond配置不工作:

  119.       

  120.     vi /etc/modprobe.conf

  121.     添加

  122.     # BONDING

  123.     alias bond1 bonding

  124.     options bond1 mode=1 miimon=100

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI