欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Linux双网卡绑定解绑

程序员文章站 2024-02-14 16:27:46
...

双网卡教程

1. 停止NetworkManager

[[email protected] ~]# service NetworkManager stop
[[email protected] ~]# chkconfig NetworkManager off

2. 手工写绑定的配置 ifcfg-bond0

[[email protected] ~]#  vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.6.216
PREFIX=24
GATEWAY=192.168.6.1
USERCTL=no
[[email protected] ~]# mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0-bak #备份本文件
[[email protected] ~]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
slave=yes
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
slave=yes
[[email protected] ~]# vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 miimon=100 mode=1

3. 开机生效

[[email protected] ~]# vi /etc/rc.d/rc.local

文档末尾增加内容

ifenslave bond0 eth0 eth1

4. 重启服务生效

[[email protected] ~]# service network restart-----远程连接断开(真实机器的话最好重启)
[[email protected] ~]# ifenslave bond0 eth0 eth1

5. 状态检查

[[email protected] ~]# ifconfig -a
[[email protected] ~]# cat /proc/net/bonding/bond0

6. 双网卡解绑

[[email protected] ~]# rm -rf /etc/sysconfig/network-scripts/ifcfg-bond0 
[[email protected] ~]# rm -rf /etc/modprobe.d/bonding.conf 
[[email protected] ~]# rm -rf /etc/sysconfig/network-scripts/ifcfg-eth0
[[email protected] ~]# rm -rf /etc/sysconfig/network-scripts/ifcfg-eth1
[[email protected] ~]# rmmod bonding
[[email protected] ~]# service network restart --远程连接断开