我正在尝试为我的家庭实验室服务器分配一系列静态 IP 地址,以便我可以运行媒体服务。
我编辑了/etc/netplan/
以下内容:
01-netcfg.yaml:
network:
version: 2
renderer: networkd
ethernets:
enp0s20f0:
dhcp4: no
addresses: [192.168.0.100/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1,8.8.4.8,8.8.8.8]
然后我对分配的另外三个端口重复此操作。例如,02-netcfg.yaml
等等。
当我跑步时
sudo netplan apply
我获得了正确的 IP 地址。
几分钟后,我丢失了分配的数字,并从路由器的 DHCP 中获得了新的 IP。
我也尝试过通过路由器设置静态 IP,但遇到同样的问题。
有什么想法吗?
(我很乐意根据需要提供更多日志。)
更新:输出自syslog
/var/log$ tail -100 syslog
Aug 19 12:13:06 mythtv-server systemd[1]: Starting Network Name Resolution...
Aug 19 12:13:06 mythtv-server systemd-resolved[14306]: Positive Trust Anchors:
Aug 19 12:13:06 mythtv-server systemd-resolved[14306]: . IN DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5
Aug 19 12:13:06 mythtv-server systemd-resolved[14306]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d
Aug 19 12:13:06 mythtv-server systemd-resolved[14306]: Negative trust anchors: 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.in-addr.arpa 20.172.in-addr.arpa 21.172.in-addr.arpa 22.172.in-addr.arpa 23.172.in-addr.arpa 24.172.in-addr.arpa 25.172.in-addr.arpa 26.172.in-addr.arpa 27.172.in-addr.arpa 28.172.in-addr.arpa 29.172.in-addr.arpa 30.172.in-addr.arpa 31.172.in-addr.arpa 168.192.in-addr.arpa d.f.ip6.arpa corp home internal intranet lan local private test
Aug 19 12:13:06 mythtv-server systemd-resolved[14306]: Using system hostname 'mythtv-server'.
Aug 19 12:13:06 mythtv-server systemd[1]: Started Network Name Resolution.
Aug 19 12:13:10 mythtv-server dhclient[11809]: DHCPDISCOVER on enp0s20f3 to 255.255.255.255 port 67 interval 11 (xid=0x80e80479)
Aug 19 12:13:10 mythtv-server dhclient[11809]: send_packet: No such device or address
Aug 19 12:13:10 mythtv-server dhclient[11809]: dhclient.c:2438: Failed to send 300 byte long packet over enp0s20f3 interface.
Aug 19 12:13:10 mythtv-server dhclient[28319]: DHCPDISCOVER on enp0s20f3 to 255.255.255.255 port 67 interval 20 (xid=0x6ab1ec09)
Aug 19 12:13:10 mythtv-server dhclient[28319]: send_packet: No such device or address
Aug 19 12:13:10 mythtv-server dhclient[28319]: dhclient.c:2438: Failed to send 300 byte long packet over enp0s20f3 interface.
Aug 19 12:13:11 mythtv-server dhclient[27706]: DHCPDISCOVER on enp0s20f3 to 255.255.255.255 port 67 interval 12 (xid=0x9f278b66)
Aug 19 12:13:11 mythtv-server dhclient[27706]: send_packet: No such device or address
Aug 19 12:13:11 mythtv-server dhclient[27706]: dhclient.c:2438: Failed to send 300 byte long packet over enp0s20f3 interface.
Aug 19 12:13:15 mythtv-server dhclient[28739]: DHCPDISCOVER on enp0s20f1 to 255.255.255.255 port 67 interval 3 (xid=0xf969ca13)
Aug 19 12:13:15 mythtv-server dhclient[28739]: send_packet: No such device or address
Aug 19 12:13:15 mythtv-server dhclient[28739]: dhclient.c:2438: Failed to send 300 byte long packet over enp0s20f1 interface.
Aug 19 12:13:18 mythtv-server dhclient[11809]: DHCPDISCOVER on enp0s20f1 to 255.255.255.255 port 67 interval 7 (xid=0x8354462)
Aug 19 12:13:18 mythtv-server dhclient[11809]: send_packet: No such device or address
Aug 19 12:13:18 mythtv-server dhclient[11809]: dhclient.c:2438: Failed to send 300 byte long packet over enp0s20f1 interface.
Aug 19 12:13:18 mythtv-server dhclient[3290]: DHCPDISCOVER on enp0s20f3 to 255.255.255.255 port 67 interval 9 (xid=0xc9123118)
Aug 19 12:13:18 mythtv-server dhclient[3290]: send_packet: No such device or address
Aug 19 12:13:18 mythtv-server dhclient[3290]: dhclient.c:2438: Failed to send 300 byte long packet over enp0s20f3 interface.
Aug 19 12:13:18 mythtv-server dhclient[28739]: DHCPDISCOVER on enp0s20f1 to 255.255.255.255 port 67 interval 6 (xid=0xf969ca13)
Aug 19 12:13:18 mythtv-server dhclient[28739]: send_packet: No such device or address
Aug 19 12:13:18 mythtv-server dhclient[28739]: dhclient.c:2438: Failed to send 300 byte long packet over enp0s20f1 interface.
Aug 19 12:13:21 mythtv-server dhclient[11809]: DHCPDISCOVER on enp0s20f3 to 255.255.255.255 port 67 interval 15 (xid=0x80e80479)
更新2:我添加了ip a
ip a
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s20f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether ac:1f:6b:46:da:74 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.100/24 brd 192.168.0.255 scope global enp0s20f0
valid_lft forever preferred_lft forever
inet 192.168.0.6/24 brd 192.168.0.255 scope global secondary dynamic enp0s20f0
valid_lft 2391sec preferred_lft 2391sec
inet6 2605:a000:45c9:3100::3/128 scope global dynamic noprefixroute
valid_lft 3277sec preferred_lft 1477sec
inet6 2605:a000:45c9:3100:ae1f:6bff:fe46:da74/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 604796sec preferred_lft 604796sec
inet6 fe80::ae1f:6bff:fe46:da74/64 scope link
valid_lft forever preferred_lft forever
3: enp0s20f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether ac:1f:6b:46:da:75 brd ff:ff:ff:ff:ff:ff
4: enp0s20f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether ac:1f:6b:46:da:76 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.102/24 brd 192.168.0.255 scope global enp0s20f2
valid_lft forever preferred_lft forever
inet 192.168.0.68/24 brd 192.168.0.255 scope global secondary dynamic enp0s20f2
valid_lft 2389sec preferred_lft 2389sec
inet6 2605:a000:45c9:3100::2/128 scope global dynamic noprefixroute
valid_lft 3379sec preferred_lft 1579sec
inet6 2605:a000:45c9:3100:ae1f:6bff:fe46:da76/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 604796sec preferred_lft 604796sec
inet6 fe80::ae1f:6bff:fe46:da76/64 scope link
valid_lft forever preferred_lft forever
5: enp0s20f3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether ac:1f:6b:46:da:77 brd ff:ff:ff:ff:ff:ff
答案1
这可能是一种可以NetworkManager
实现这一点的服务。就purge
这么办吧,希望它能发挥作用。
有关如何清除它的更多详细信息,请转到:如何永久禁用网络管理器?
注意:
(来源 :Ubuntu 18.04 及更高版本上的 netplan 与 NetworkManager)
NetworkManager
通常用于桌面应用程序,并在 Ubuntu 的所有先前版本中使用。如果你正在使用
netplan
,删除是完全安全的NetworkManager
在 Ubuntu 18.04.3 LTS 上为我修复了同样的问题。
答案2
查看 netplan 上的这个相关错误...
https://bugs.launchpad.net/netplan/+bug/1781652
如果您仍然遇到 netplan 问题,您可以轻松迁移回 ifupdown。我确实这样做了。