繼昨天快速地介紹完 VLAN 後,我們來設定一下
目前是要在 PVE 與路由器進行設定。
我的路由器為 x86 Linux 系統,而 PVE 則是使用 Open vSwitch。
100 家用網路
200 VM 用內網
300 ISP Public IP
這邊以 netplan 為例,提供 netplan 設定檔的 yaml 給大家參考
PS. 請進入 /etc/netplan/
進行編輯
# vlan.300 的範例換成其他 IP 了(安全起見)
network:
version: 2
ethernets:
enp1s0:
addresses: [127.0.0.1/32]
vlans:
vlan.0:
id: 0
link: enp1s0
addresses: [10.121.213.254/24]
vlan.100:
id: 100
link: enp1s0
addresses: [10.121.211.254/24]
vlan.200:
id: 200
link: enp1s0
addresses: []
vlan.300:
accept-ra: false
id: 300
link: enp1s0
addresses: [7.1.1.2/24]
gateway4: 7.1.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
search: [network.steveyi.net]
進到 PVE Web Console,Bridge Ports 請設定為 實體網卡.VLANID
以下為 Juniper EX2200-C 為例
l3-interface
set vlans home-internal vlan-id 100
set vlans home-internal l3-interface vlan.100
set vlans yi-network vlan-id 200
set vlans yi-network l3-interface vlan.200
set vlans seednet vlan-id 300
set vlans seednet l3-interface vlan.300
set interfaces ge-0/0/1 description PVE-PC
set interfaces ge-0/0/1 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-0/0/1 unit 0 family ethernet-switching vlan members all
ge-0/0/1 {
description PVE-PC;
unit 0 {
family ethernet-switching {
port-mode trunk;
vlan {
members all;
}
}
}
}
commit and-quit