/etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens192:
dhcp4: true
version: 2
/运行/systemd/network/10-netplan-ens192.network
[Match]
Name=ens192
[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
[DHCP]
RouteMetric=100
UseMTU=true
ip-4a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 217.160.244.97/32 scope global dynamic ens192
valid_lft 39392sec preferred_lft 39392sec
ip -4 路由
default via 10.255.255.1 dev ens192 proto dhcp src 217.160.244.97 metric 100
10.255.255.1 dev ens192 proto dhcp scope link src 217.160.244.97 metric 100
服务 systemd-networkd 状态
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-05-11 06:30:58 UTC; 1h 5min ago
TriggeredBy: ● systemd-networkd.socket
Docs: man:systemd-networkd.service(8)
Main PID: 928 (systemd-network)
Status: "Processing requests..."
Tasks: 1 (limit: 38422)
Memory: 3.8M
CGroup: /system.slice/systemd-networkd.service
└─928 /lib/systemd/systemd-networkd
May 11 06:30:58 local systemd[1]: Starting Network Service...
May 11 06:30:58 local systemd-networkd[928]: Enumeration completed
May 11 06:30:58 local systemd[1]: Started Network Service.
May 11 06:30:58 local systemd-networkd[928]: ens192: IPv6 successfully enabled
May 11 06:30:58 local systemd-networkd[928]: ens192: Link UP
May 11 06:30:58 local systemd-networkd[928]: ens192: Gained carrier
May 11 06:30:58 local systemd-networkd[928]: ens192: DHCPv4 address 217.160.244.97/32 via 10.255.255.1
May 11 06:30:58 local systemd-networkd[928]: ens192: Could not set DHCPv4 route: Nexthop has invalid gateway. Network is unreachable
May 11 06:30:58 local systemd-networkd[928]: ens192: Failed
我不知道如何解决这个问题!几天前我一直在尝试解决这个问题,但仍然没有找到答案。
答案1
我发现在文件 /etc/netplan/00-installer-config.yaml 中添加“critical: true”可确保接口不会定期关闭(似乎是 IONOS 的问题)。该文件应如下所示:
# This is the network config written by 'subiquity'
network:
ethernets:
ens192:
dhcp4: true
critical: true
version: 2
然后运行:
$ sudo netplan generate
$ sudo netplan apply
这应该有助于解决任何网络中断问题。
答案2
你只需要执行UseRoutes=no
,但要激活UseGateway=yes
。你可以看看我的默认配置。
/etc/systemd/network/default.network
[Match]
Type=!loopback
[Link]
RequiredForOnline=yes
[Network]
DHCP=yes
[DHCPv4]
UseRoutes=no
UseGateway=yes