Ubuntu bonding + vlan

Posted Hi,云计算!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu bonding + vlan相关的知识,希望对你有一定的参考价值。

系统版本: Ubuntu 14.04 (4.4.0)

 

创建bonding

1.  系统自动加载 bonding模块

[email protected]:~$ 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. 配置网卡

[email protected]:~$ 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模块

[email protected]:/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.配置网卡

[email protected]:~$ 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)

 

脚本小记:

[email protected]:/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

 

以上是关于Ubuntu bonding + vlan的主要内容,如果未能解决你的问题,请参考以下文章

Centos bonding +vlan

KVM配置BOND,BRIDGE,VLAN

配置bond和vlan

ovs 实现vlan隔离

Configure a bridge interface over a VLAN tagged bonded interface

Neutron — Bonding SR-IOV ports