kvm虚拟化配置vlan网络模式,本文以新增2个vlan为例讲解
前提:
一、在物理机上
1、检查是否支持8021q
[root
@node1 ~]
8021q
25317 0
garp
7152 1 8021q
2、在物理机上增加2个vlan( 注意前提是这2个vlan必须在物理交换机上面已经存在),必须每次执行这些,并重启网络。
[root
@node1 ~]
Added VLAN with
VID ==
401 to
IF -
:eth1:-
[root
@node1 ~]
Added VLAN with
VID ==
402 to
IF -
:eth1:-
3、验证如下:
[root
@node1 ~]
vnet
0 Link encap:Ethernet HWaddr FE:54:00:35:92:92
inet6
addr: fe80::fc54:ff:fe35:9292/
64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:496 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:300 (
300.0 b)
TX bytes:26240 (
25.6 KiB)
vnet1
Link encap:Ethernet HWaddr FE:54:00:39:D0:41
inet6
addr: fe80::fc54:ff:fe39:d041/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:490 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:300 (
300.0 b)
TX bytes:25896 (
25.2 KiB)
4、增加这2个vlan的配置
[root@node1 network-scripts]
DEVICE="br401"
TYPE=Bridge
ONBOOT="yes"
[root@node1 network-scripts]
DEVICE="eth1.401"
BRIDGE="br401"
ONBOOT="yes
[root@node1 network-scripts]
DEVICE="br402"
TYPE=Bridge
ONBOOT="yes"
[root@node1 network-scripts]
DEVICE="eth1.402"
BRIDGE="br402"
ONBOOT="yes
5、重启网络
[root
@node1 ~]
6、重启网络之后,验证如下:
[root
@node1 ~]
br401
Link encap:Ethernet HWaddr 5C:F3:FC:B7:DF:0E
inet6
addr: fe80::5ef3:fcff:feb7:df0e/
64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (
0.
0 b)
TX bytes:468 (
468.0 b)
br402
Link encap:Ethernet HWaddr 5C:F3:FC:B7:DF:0E
inet6
addr: fe80::5ef3:fcff:feb7:df0e/
64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (
0.
0 b)
TX bytes:468 (
468.0 b)
eth
0 Link encap:Ethernet HWaddr 5C:F3:FC:B7:DF:0C
inet
addr:192.168.
62.150 Bcast:192.168.
62.191 Mask:255.255.
255.192
inet6
addr: fe80::5ef3:fcff:feb7:df0c/
64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8807 errors:0 dropped:0 overruns:0 frame:0
TX packets:13705 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1209387 (
1.1 MiB)
TX bytes:16803742 (
16.0 MiB)
eth1
Link encap:Ethernet HWaddr 5C:F3:FC:B7:DF:0E
inet6
addr: fe80::5ef3:fcff:feb7:df0e/
64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2923 errors:0 dropped:0 overruns:0 frame:0
TX packets:34 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:291845 (
285.0 KiB)
TX bytes:3820 (
3.7 KiB)
eth1.
401 Link encap:Ethernet HWaddr 5C:F3:FC:B7:DF:0E
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:233 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:15591 (
15.2 KiB)
TX bytes:1488 (
1.4 KiB)
eth1.
402 Link encap:Ethernet HWaddr 5C:F3:FC:B7:DF:0E
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:115 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16079 (
15.7 KiB)
TX bytes:692 (
692.0 b)
eth2
Link encap:Ethernet HWaddr 00:1B:21:C0:56:70
inet6
addr: fe80::21b:21ff:fec0:5670/
64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (
0.
0 b)
TX bytes:26586 (
25.9 KiB)
Memory:97a8000
0-
97b0000
0
eth3
Link encap:Ethernet HWaddr 00:1B:21:C0:56:71
inet6
addr: fe80::21b:21ff:fec0:5671/
64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:266 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17922 (
17.5 KiB)
TX bytes:2646 (
2.5 KiB)
Memory:97a0000
0-
97a8000
0
lo
Link encap:Local Loopback
inet
addr:127.0.
0.
1 Mask:255.0.
0.
0
inet6
addr: ::1/
128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:195275 errors:0 dropped:0 overruns:0 frame:0
TX packets:195275 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:196514662 (
187.4 MiB)
TX bytes:196514662 (
187.4 MiB)
virbr
0 Link encap:Ethernet HWaddr 52:54:00:78:65:D5
inet
addr:192.168.
122.1 Bcast:192.168.
122.255 Mask:255.255.
255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:460 (
460.0 b)
TX bytes:0 (
0.
0 b)
7、ifcfg-eth1的配置
[root@node1 ~]
DEVICE=eth1
HWADDR=5C:F3:FC:B7:DF:0E
TYPE=Ethernet
UUID=ccc25098-ac10-46b9-936c-f5db3155ecd9
ONBOOT=yes
NM_CONTROLLED=no
二、虚拟机的配置
1、验证eth1.401网络
2、验证eth1.402网络
3、配置虚拟机test1的网卡1选择eth1.401网络
三、
1、启动虚拟机test1之前
[root
@node1 ~]
bridge name bridge id STP enabled interfaces
br401
8000.5cf3fcb7df0e
no eth1
.401
br402
8000.5cf3fcb7df0e
no eth1
.402
virbr0
8000.5254007865d5
yes virbr0-nic
[root
@node1 ~]
2、启动虚拟机test1之后
[root
@node1 ~]
bridge name bridge id STP enabled interfaces
br401
8000.5cf3fcb7df0e
no eth1
.401
vnet0
br402
8000.5cf3fcb7df0e
no eth1
.402
virbr0
8000.5254007865d5
yes virbr0-nic
转载请注明原文地址: https://ju.6miu.com/read-25686.html