跳转至

07-系统网卡配置-centos7.x

配置单网卡模式

[root@192e168e2e14 network-scripts]# cat ifcfg-eth1 
TYPE=Ethernet
NAME=eth1
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.11.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500

配置单网卡+单vlan模式

[root@192e168e2e14 network-scripts]# cat ifcfg-eth2
NAME=eth2
DEVICE=eth2
ONBOOT=yes
USERCTL=no
BOOTPROTO=static
[root@192e168e2e14 network-scripts]# cat ifcfg-eth2.300 
TYPE=Vlan
VLAN=yes
VID=300
NAME=eth2.300
DEVICE=eth2.300
BOOTPROTO=static
ONBOOT=yes
PHYSDEV=eth2
USERCTL=no
IPADDR=192.168.12.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500

配置单网卡+多vlan模式

[root@192e168e2e14 network-scripts]# cat ifcfg-eth2
NAME=eth2
DEVICE=eth2
ONBOOT=yes
USERCTL=no
BOOTPROTO=static
[root@192e168e2e14 network-scripts]# cat ifcfg-eth2.300
TYPE=Vlan
VLAN=yes
VID=300
NAME=eth2.300
DEVICE=eth2.300
BOOTPROTO=static
ONBOOT=yes
PHYSDEV=eth2
USERCTL=no
IPADDR=192.168.12.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500

[root@192e168e2e14 network-scripts]# cat ifcfg-eth2.301
TYPE=Vlan
VLAN=yes
VID=301
NAME=eth2.301
DEVICE=eth2.301
BOOTPROTO=static
ONBOOT=yes
PHYSDEV=eth2
USERCTL=no
IPADDR=192.168.13.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500

[root@192e168e2e14 network-scripts]# cat ifcfg-eth2.302
TYPE=Vlan
VLAN=yes
VID=302
NAME=eth2.302
DEVICE=eth2.302
BOOTPROTO=static
ONBOOT=yes
PHYSDEV=eth2
USERCTL=no
IPADDR=192.168.14.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500

配置多网卡bond模式

[root@192e168e2e14 network-scripts]# cat ifcfg-bond2-slave-eth1 
TYPE=Ethernet
NAME=bond2-slave-eth1
DEVICE=eth1
ONBOOT=yes
MASTER=bond2
SLAVE=yes
MTU=9000
[root@192e168e2e14 network-scripts]# cat ifcfg-bond2-slave-eth2
TYPE=Ethernet
NAME=bond2-slave-eth2
DEVICE=eth2
ONBOOT=yes
MASTER=bond2
SLAVE=yes
MTU=9000
[root@192e168e2e14 network-scripts]# cat ifcfg-bond2-slave-eth3
TYPE=Ethernet
NAME=bond2-slave-eth3
DEVICE=eth3
ONBOOT=yes
MASTER=bond2
SLAVE=yes
MTU=9000
[root@192e168e2e14 network-scripts]# cat ifcfg-bond2-slave-eth4
TYPE=Ethernet
NAME=bond2-slave-eth4
DEVICE=eth4
ONBOOT=yes
MASTER=bond2
SLAVE=yes
MTU=9000
[root@192e168e2e14 network-scripts]# cat ifcfg-bond2
TYPE=Bond
NAME=bond2
DEVICE=bond2
BONDING_OPTS="mode=6 miimon=100"
BONDING_MASTER=yes
BOOTPROTO=static
ONBOOT=yes
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPADDR=
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=9000

配置多网卡bond+单vlan模式

[root@192e168e2e14 network-scripts]# cat ifcfg-bond2-slave-eth3 
TYPE=Ethernet
NAME=bond2-slave-eth3
DEVICE=eth3
ONBOOT=yes
MASTER=bond2
SLAVE=yes
MTU=9000
[root@192e168e2e14 network-scripts]# cat ifcfg-bond2-slave-eth4
TYPE=Ethernet
NAME=bond2-slave-eth4
DEVICE=eth4
ONBOOT=yes
MASTER=bond2
SLAVE=yes
MTU=9000
[root@192e168e2e14 network-scripts]# cat ifcfg-bond2
TYPE=Bond
NAME=bond2
DEVICE=bond2
BONDING_OPTS="mode=6 miimon=100"
BONDING_MASTER=yes
BOOTPROTO=static
ONBOOT=yes
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
MTU=9000
[root@192e168e2e14 network-scripts]# cat ifcfg-bond2.301 
TYPE=Vlan
NAME=bond2.301
DEVICE=bond2.301
PHYSDEV=bond2
VID=301
VLAN=yes
ISALIAS=no
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.14.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=9000

配置多网卡bond+多vlan模式

[root@192e168e2e14 network-scripts]# cat ifcfg-bond0-slave-eth1 
TYPE=Ethernet
NAME=bond0-slave-eth1
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
MTU=1500
[root@192e168e2e14 network-scripts]# cat ifcfg-bond0-slave-eth2
TYPE=Ethernet
NAME=bond0-slave-eth2
DEVICE=eth2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
MTU=1500
[root@192e168e2e14 network-scripts]# cat ifcfg-bond0
TYPE=Bond
NAME=bond0
DEVICE=bond0
BONDING_OPTS="mode=6 miimon=100"
BONDING_MASTER=yes
BOOTPROTO=static
ONBOOT=yes
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
MTU=1500
[root@192e168e2e14 network-scripts]# cat ifcfg-bond0.111 
TYPE=Vlan
NAME=bond0.111
DEVICE=bond0.111
PHYSDEV=bond0
VID=111
VLAN=yes
ISALIAS=no
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.11.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500

[root@192e168e2e14 network-scripts]# cat ifcfg-bond0.112
TYPE=Vlan
NAME=bond0.112
DEVICE=bond0.112
PHYSDEV=bond0
VID=112
VLAN=yes
ISALIAS=no
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.12.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500

[root@192e168e2e14 network-scripts]# cat ifcfg-bond0.113
TYPE=Vlan
NAME=bond0.113
DEVICE=bond0.113
PHYSDEV=bond0
VID=113
VLAN=yes
ISALIAS=no
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.13.14
NETMASK=255.255.255.0
GATEWAY=
DNS1=
MTU=1500