一:linux操作系统下双网卡绑定有七种模式。
一共七种方式,其中比较长用的是0/1/6:
首先,虚拟机或物理机上有4块网卡,eth0-3;eht0-1做绑定,用于外网连通;eth2-3做成绑定,用于内网连通。
1,绑定内网网卡到bond1:
1.1 第一组配置,将eth2和eth3绑定到bond1:
[root@kvm-1 network-scripts]# cat ifcfg-bond1
BOOTPROTO=none
NAME=bond1
DEVICE=bond1
TYPE=Bond
BONDING_MASTER=YES
ONBOOT=YES
BONDING_OPTS="mode=1 miimon=100" #指定绑定类型为1及链路状态监测间隔时间
BRIDGE=br1 #桥接到br1
1.2 配置br1:
[root@kvm-1 network-scripts]# cat ifcfg-br1
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=YES
PEERDNS=YES
PEERROTUES=YES
NAME=br1
DEVICE=br1
ONBOOT=YES
IPADDR=172.16.36.70
PREFIX=24
1.3 配置eth2:
[root@kvm-1 network-scripts]# cat ifcfg-eth2
# Generated by parse-kickstart
IPV6INIT="no"
IPV6_AUTOCONF="no"
BOOTPROTO="none"
DEVICE="eth2"
ONBOOT="yes"
MASTER=bond1 #主节点
USERCTL=no #是否允许非root用户控制该设备
SLAVE=yes #从节点
1.4 配置eth3:
[root@kvm-1 network-scripts]# cat ifcfg-eth3
# Generated by parse-kickstart
IPV6INIT="no"
IPV6_AUTOCONF="no"
BOOTPROTO="none"
DEVICE="eth3"
ONBOOT="yes"
MASTER=bond1 #主节点
USERCTL=no #是否允许非root用户控制该设备
SLAVE=yes #从节点
1.5 重启网络生效,并验证连通性:
[root@kvm-1 network-scripts]# systemctl restart network
[root@kvm-1 network-scripts]# ping 172.16.36.1
PING 172.16.36.1 (172.16.36.1) 56(84) bytes of data.
64 bytes from 172.16.36.1: icmp_seq=1 ttl=64 time=0.552 ms
64 bytes from 172.16.36.1: icmp_seq=2 ttl=64 time=1.12 ms
64 bytes from 172.16.36.1: icmp_seq=3 ttl=64 time=6.54 ms
64 bytes from 172.16.36.1: icmp_seq=4 ttl=64 time=1.37 ms
2, 绑定外网网卡到bond0
2.1 第二组配置,将eth0和eth1绑定到bond0:
[root@kvm-1 network-scripts]# cat ifcfg-bond0
BOOTPROTO=none
NAME=bond0
DEVICE=bond0
TYPE=Bond
BONDING_MASTER=YES
ONBOOT=YES
BONDING_OPTS="mode=1 miimon=100"
BRIDGE=br0
2.2 配置br0:
[root@kvm-1 network-scripts]# cat ifcfg-br0
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=YES
PEERDNS=YES
PEERROTUES=YES
NAME=br0
DEVICE=br0
ONBOOT=YES
IPADDR=172.20.44.190
PREFIX=16
GATEWAY=172.20.0.1
DNS1=202.106.0.20
2.3 配置eth0:
[root@kvm-1 network-scripts]# cat ifcfg-eth0
# Generated by parse-kickstart
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
BOOTPROTO="none"
DEVICE="eth0"
ONBOOT="yes"
MASTER=bond0
USERCTL=no
SLAVE=yes
2.4 配置eth1:
[root@kvm-1 network-scripts]# cat ifcfg-eth1
# Generated by parse-kickstart
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
BOOTPROTO="none"
DEVICE="eth1"
ONBOOT="yes"
MASTER=bond0
USERCTL=no
SLAVE=yes
2.5 重启网络生效,并验证连通性:
[root@kvm-1 network-scripts]# systemctl restart network
[root@kvm-1 network-scripts]# ping 172.20.0.1
PING 172.20.0.1 (172.20.0.1) 56(84) bytes of data.
From 172.20.240.150 icmp_seq=1 Redirect Network(New nexthop: 172.20.0.1)
From 172.20.240.150 icmp_seq=1 Redirect Network(New nexthop: 172.20.0.1)
From 172.20.240.150 icmp_seq=1 Redirect Network(New nexthop: 172.20.0.1)
From 172.20.240.150: icmp_seq=1 Redirect Network(New nexthop: 172.20.0.1)
From 172.20.240.150: icmp_seq=1 Redirect Network(New nexthop: 172.20.0.1)
From 172.20.240.150: icmp_seq=1 Redirect Network(New nexthop: 172.20.0.1)