当前位置首页 > Debian知识

debian8.2bond双网卡

阅读次数:205 次  来源:admin  发布时间:

安装 debian 8.2

eth0

eth1

eth2

onding模块工作方式

onding有0-6七种模式,常用的工作方式为0、1、6三种:

0: (balance-rr) Round-robin policy: (平衡抡循环策略):传输数据包顺序是依次传输,直到最后一个传输完毕,

此模式提供负载平衡和容错能力。

1: (active-backup) Active-backup policy:(主-备份策略):只有一个设备处于活动状态。 一个宕掉另一个马上由

备份转换为主设备。mac地址是外部可见得。

此模式提供了容错能力。

2: (balance-xor) XOR policy:(广播策略):将所有数据包传输给所有接口。

此模式提供了容错能力。

3: (balance-xor) XOR policy:(平衡策略): 传输根据原地址布尔值选择传输设备。

此模式提供负载平衡和容错能力。

4: (802.3ad) IEEE 802.3ad Dynamic link aggregation.IEEE 802.3ad 动态链接聚合:创建共享相同的速度和

双工设置的聚合组。

5: (balance-tlb) Adaptive transmit load balancing(适配器传输负载均衡):没有特殊策略,第一个设备传不通就用

另一个设备接管第一个设备正在处理的mac地址,帮助上一个传。

6: (balance-alb) Adaptive load balancing:(适配器传输负载均衡):大致意思是包括mode5,bonding驱动程序

截获 ARP 在本地系统发送出的请求,用其中之一的硬件地址覆盖从属设备的原地址。就像是在服务器上不同的人

使用不同的硬件地址一样

本次参考主库,采用 模式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)

删除vi

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

# /etc/init.d/networking restart

创建vi

# 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
上一篇:Windows10下安装Debian和图形界面操作
下一篇:关于debian10buster使用最新搜狗输入法(2.4.0.3469)不能使用下载的ssf皮肤问题