ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux下双网卡绑定

linux下双网卡绑定

原创 Linux操作系统 作者:gqh2789 时间:2017-06-26 16:51:15 0 删除 编辑


点击(此处)折叠或打开

  1. Linux下的双网卡绑定
  2.     将eth0,eth1绑定为bond0 ,节点内部通信用,使用192.168.1.0网段。
  3.     将eth2,eth3绑定为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,eth1绑定为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-eth1
  37.     DEVICE=eth1
  38.     BOOTPROTO=none
  39.     ONBOOT=yes
  40.     USERCTL=no
  41.     MASTER=bond0
  42.     SLAVE=yes
  43.       
  44.       
  45.     <2>
  46.     将eth2,eth3绑定为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-eth2
  62.     DEVICE=eth2
  63.     BOOTPROTO=none
  64.     ONBOOT=yes
  65.     USERCTL=no
  66.     MASTER=bond1
  67.     SLAVE=yes
  68.       
  69.       
  70.     vi /etc/sysconfig/network-scripts/ifcfg-eth3
  71.     DEVICE=eth3
  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 eth1
  97.     ifenslave bond1 eth2 eth3
  98.       
  99.     启动网卡
  100.     ifconfig bond0 192.168.1.2 up
  101.     ifenslave bond0 eth0 eth1
  102.       
  103.     ifconfig bond1 10.12*.*.61 up
  104.     ifenslave bond1 eth2 eth3
  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

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

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

注册时间:2016-05-13

  • 博文量
    51
  • 访问量
    59862