声明:本站文章皆基于公开来源信息,仅代表作者个人观点,与作者所在公司无关!

Ubuntu bonding + vlan

系统版本: Ubuntu 14.04 (4.4.0)

 

创建bonding

1.  系统自动加载 bonding模块

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. 配置网卡

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

 

创建Vlan

1.  系统自动加载 8021q模块

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.配置网卡

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)

          2. 如果网卡需要开机启动且不需要IP, 需要使用manual (dhcp/static/manual)

 

脚本小记:

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

 

posted @ 2018-05-30 19:04  Hi,云计算!  阅读(695)  评论(0编辑  收藏  举报