Ubuntu bonding + vlan

系統版本: Ubuntu 14.04 (4.4.0)ubuntu

 

建立bondingoop

1.  系統自動加載 bonding模塊spa

ubuntu@bogon:~$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
bonding

 

 2. 安裝 ifenslave 插件插件

apt-get install ifenslave

 

  3. 配置網卡code

ubuntu@bogon:~$ cat /etc/network/interfaces
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback


up ifenslave bond0 enp0s3 enp0s8
down ifenslave -d bond0 enp0s3 enp0s8

auto bond0
iface bond0 inet dhcp  #此處配置須要正常啓動, 不然沒法模塊4 設備失敗
bond-mode 4
bond-miimon 100
bond-slaves enp0s3 enp0s8

 

建立Vlanorm

1.  系統自動加載 8021q模塊blog

root@bogon:/home/ubuntu# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
bonding
8021q

 

2.配置網卡get

ubuntu@bogon:~$ cat /etc/network/interfaces
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback


up ifenslave bond0 enp0s3 enp0s8
down ifenslave -d bond0 enp0s3 enp0s8

auto bond0
iface bond0 inet dhcp
bond-mode 4
bond-miimon 100
bond-slaves enp0s3 enp0s8

auto vlan41
iface vlan41 inet static
address 192.168.10.10
netmask 255.255.255.0
network 192.168.10.0
broadcast 192.168.10.255
vlan-raw-device bond0

 

注意:  1. bonding模塊默認支持一個bond, 若是須要建立2個bond, 配置/etc/modprobe.d/bonding.conf  *(options bonding max_bonds=2)it

          2. 若是網卡須要開機啓動且不須要IP, 須要使用manual (dhcp/static/manual)io

 

腳本小記:

root@bogon:/home/ubuntu# cat /etc/network/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


up (ifenslave bond0 enp0s3; \
    ifenslave bond1 enp0s8)
down (ifenslave -d bond0 enp0s3; \
      ifenslave -d bond1 enp0s8)

auto bond0
iface bond0 inet dhcp
bond-mode 4
bond-miimon 100
bond-slaves enp0s3

auto bond1
iface bond1 inet static
bond-mode 0
bond-miimon 100
address 192.168.230.100
netmask 255.255.255.0
network 192.168.230.0
broadcast 192.168.230.255

auto vlan41
iface vlan41 inet static
address 192.168.10.10
netmask 255.255.255.0
network 192.168.10.0
broadcast 192.168.10.255
vlan-raw-device bond1
相關文章
相關標籤/搜索