debian 8.2 双网卡绑定 bonding

os: debian 8.2

eth0
eth1

eth2

bonding 有 0-6 七种模式

第一种模式:mod=0,即:(balance-rr)Round-robin policy(平衡抡循环策略)交换机配置Eth-Trunk
第二种模式:mod=1,即:(active-backup)Active-backup policy(主-备份策略)
第三种模式:mod=2,即:(balance-xor)XOR policy(平衡策略)
第四种模式:mod=3,即:broadcast(广播策略)
第五种模式:mod=4,即:(802.3ad)IEEE 802.3ad Dynamic link aggregation(IEEE802.3ad 动态链接聚合)
第六种模式:mod=5,即:(balance-tlb)Adaptive transmit load balancing(适配器传输负载均衡)
第七种模式:mod=6,即:(balance-alb)Adaptive load balancing(适配器适应性负载均衡)

本次参考主库,采用 模式1

安装ifenslave,用作bonding

# apt-get install ifenslave

让系统开机自动加载模块bonding

# echo "bonding" >> /etc/modules

没有重启需要手动添加进linux 内核

# modprobe bonding

创建vip bond

# cd /etc/network/interfaces.d
# vi bond0:1

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The bond0:1 network interface
auto bond0:1 
iface bond0:1 inet static
	address 192.168.56.99
	netmask 255.255.255.0
	network 192.168.56.0
	gateway 192.168.56.1

添加如下网卡配置文件

# vi /etc/network/interfaces

# The primary network interface
auto bond0
iface bond0 inet static
        address 192.168.56.100
        netmask 255.255.255.0
        gateway 192.168.56.1
 bond-mode 1
 bond-primary eth0
 bond-slaves eth0 eth1
 bond-miimon 100
 bond-downdelay 400
 bond-updelay 800
#post-up ifenslave bond0 eth0 eth1
#pre-down ifenslave -d bond0 eth0 eth1

重新启动网卡

# /etc/init.d/networking restart

配置网卡信息**************/

# cd /etc/network/interfaces.d/
# ls -l
总用量 4
-rw-r--r-- 1 root root 137 6月  21 19:19 bond0:1
# cat bond0:1 
auto bond0:1 
iface bond0:1 inet static
	address 192.168.56.99
	netmask 255.255.255.0
	network 192.168.56.0
  gateway 192.168.56.1

# cd /etc/network
# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*  #*/

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto bond0
iface bond0 inet static
        address 192.168.56.100
        netmask 255.255.255.0
        gateway 192.168.56.1
 bond-mode 1
 bond-primary eth0
 bond-slaves eth0 eth1
 bond-miimon 100
 bond-downdelay 400
 bond-updelay 800


up   route del default gw 192.168.56.1
down route del default gw 192.168.56.1

auto eth2
iface eth2 inet static
address 10.234.99.184
netmask 255.255.255.0
gateway 10.234.99.212

up   route del default gw 10.234.99.212
down route del default gw 10.234.99.212 

up   route add default gw 10.234.99.7
down route add default gw 10.234.99.7


# ifconfig -a
bond0     Link encap:Ethernet  HWaddr 08:00:27:7c:70:24  
          inet addr:192.168.56.100  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7c:7024/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:100 errors:0 dropped:7 overruns:0 frame:0
          TX packets:157 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:9967 (9.7 KiB)  TX bytes:20953 (20.4 KiB)

bond0:1   Link encap:Ethernet  HWaddr 08:00:27:7c:70:24  
          inet addr:192.168.56.99  Bcast:192.168.56.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

eth0      Link encap:Ethernet  HWaddr 08:00:27:7c:70:24  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:93 errors:0 dropped:0 overruns:0 frame:0
          TX packets:157 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:9511 (9.2 KiB)  TX bytes:20953 (20.4 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:7c:70:24  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:7 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:456 (456.0 B)  TX bytes:0 (0.0 B)

eth2      Link encap:Ethernet  HWaddr 08:00:27:92:4c:bd  
          inet addr:10.234.99.184  Bcast:10.234.99.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe92:4cbd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:830 errors:0 dropped:0 overruns:0 frame:0
          TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:70259 (68.6 KiB)  TX bytes:10501 (10.2 KiB)

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:65536  Metric:1
          RX packets:83 errors:0 dropped:0 overruns:0 frame:0
          TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:26004 (25.3 KiB)  TX bytes:26004 (25.3 KiB)

删除vip

# ifquery --list
lo
bond0:1
bond0
eth2
# cd /etc/network/interfaces.d/
# mv ./bond0:1 ../

# /etc/init.d/networking restart

创建vip

# cd /etc/network/interfaces.d
# vi bond0:1 
auto bond0:1 
iface bond0:1 inet static
  address 192.168.56.99
  netmask 255.255.255.0
  network 192.168.56.0
  gateway 192.168.56.1

# ifquery --list
lo
bond0:1
bond0
eth2

# /etc/init.d/networking restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库人生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值