我尝试从 迁移ifupdown
到netplan
,但结果总是不一样。
netplan
像这样的配置的正确配置是什么networking
:
auto lo
iface lo inet loopback
auto eno0
iface eno0 inet static
address xxx.xxx.51.20/24
gateway xxx.xxx.51.254
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up echo 1 > /proc/sys/net/ipv4/conf/eno0/proxy_arp
auto vmbr0
iface vmbr0 inet static
address xxx.xxx.198.104/24
bridge-ports none
bridge-stp off
bridge-fd 0
auto vmbr1
iface vmbr1 inet static
address xxx.xxx.198.105/24
bridge-ports none
bridge-stp off
bridge-fd 0
auto vmbr2
iface vmbr2 inet static
address xxx.xxx.198.106/24
bridge-ports none
bridge-stp off
bridge-fd 0
auto vmbr3
iface vmbr3 inet static
address xxx.xxx.198.107/24
bridge-ports none
bridge-stp off
bridge-fd 0
答案1
经过几天的反复试验,我发现目前 [netplan 尚不支持 macvlan bridge][5],我们需要一种解决方法并改变systemd
网络:
- 我们需要在上创建一些文件
/etc/systemd/network
,因此导航到目录:
$ cd /etc/systemd/network
- 定义网桥的vlan,请更改
cat
为您的编辑器
$ cat 00-vmvlan0.netdev
[NetDev]
Name=vmvlan0
Kind=macvlan
# Optional MAC address, or other options
MACAddress=xx:xx:xx:xx:26:12
[MACVLAN]
Mode=bridge
$ cat 00-vmvlan0.network
[Match]
Name=vmvlan0
[Network]
Address=xxx.xxx.198.104/32
IPForward=yes
ConfigureWithoutCarrier=yes
- 定义桥梁
$ cat 00-vmbr0.netdev
[NetDev]
Name=vmbr0
Kind=bridge
$ cat 00-vmbr0.network
[Match]
Name=vmbr0
[Network]
MACVLAN=vmvlan0
- 对下一个 IP 重复上述操作
- 链接桥、vlan 和接口:
$ cat 10-netplan-eno1.link
[Match]
MACAddress=xx:xx:xx:xx:19:d0
[Link]
Name=eno1
WakeOnLan=off
$ cat 10-netplan-eno1.network
[Match]
MACAddress=xx:xx:xx:xx:19:d0
Name=eno1
[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
MACVLAN=vmvlan0
MACVLAN=vmvlan1
MACVLAN=vmvlan2
MACVLAN=vmvlan3
[DHCP]
RouteMetric=100
UseMTU=true
- 我们可以使用默认的 netplan 配置:
$ sudo cat /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
eno1:
dhcp4: true
match:
macaddress: xx:xx:xx:2a:19:d0
set-name: eno1