我正在使用 VMware photon OS VM。
我想为我的eth0
接口配置一个辅助 IP 地址。并按照以下引导:如何使用 Systemd-Networkd 配置接口别名?
我添加了额外的Address
和Gateway
值,如下所示:
[Match]
Name=eth0
[Network]
DHCP=no
Address=10.196.57.202/23
Gateway=10.196.57.253
Address=10.196.57.203/23
Gateway=10.196.57.253
DNS=10.202.22.165
LinkLocalAddressing=no
IPv6AcceptRA=no
202 是主端口,203 是辅端口:
root@fgh-57-202 [ /etc/systemd/network ]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:b8:8f:20 brd ff:ff:ff:ff:ff:ff
inet 10.196.57.202/23 brd 10.196.57.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.196.57.203/23 brd 10.196.57.255 scope global secondary eth0
valid_lft forever preferred_lft forever
但是,重新启动后,文件的内容:/etc/systemd/network/10-eth0.network
被重置为:
[Match]
Name=eth0
[Network]
DHCP=no
Address=10.196.57.202/23
Gateway=10.196.57.253
DNS=10.202.22.165
LinkLocalAddressing=no
IPv6AcceptRA=no
我检查了dhclient.conf
但没有发现任何可疑的东西:
root@fgh-57-202 [ /etc/systemd/network ]# cat /etc/dhcp/dhclient.conf
# Begin /etc/dhcp/dhclient.conf
#
# Basic dhclient.conf(5)
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
ntp-servers;
require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
# End /etc/dhcp/dhclient.conf
我正在尝试让辅助地址在重启后继续保留。