尝试在两个 NIC 之一上设置固定 IP 地址。我尝试使用 netplan。完全不起作用。
我不是这方面的专家,我疯了,准备回滚到其他方式(网络化)。也许有人能提供一些有用的建议。任何帮助/评论都非常感谢!
(一个问题:
1)启动后,enp2s0 没有分配 ip4 地址
2)这也不可能通过
- :~$ sudo netplan generate
- :~$ sudo netplan apply
顺便说一句,之前尝试更改接口名称,但也没有效果。
(B)系统配置:
:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
不管我用 netplan 做了什么尝试,下面的内容仍然完全没有变化(只是为了保护隐私而省略了地址):
:~$ ip a s
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: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether --omitted-- brd ff:ff:ff:ff:ff:ff
3: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether --omitted-- brd ff:ff:ff:ff:ff:ff
inet 192.168.2.117/24 brd 192.168.2.255 scope global dynamic enp3s0
valid_lft 1814043sec preferred_lft 1814043sec
inet6 --omitted-- scope global dynamic mngtmpaddr noprefixroute
valid_lft 604790sec preferred_lft 86390sec
inet6 --omitted-- scope link
valid_lft forever preferred_lft forever
Netplan 似乎是“官方”设置:
:~$ cat /etc/network/interfaces
# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
# sudo apt install ifupdown
这是我的 netplan 配置,它似乎验证了,因为 netplan 调用不会引发错误。只有一个 yaml 文件。
:~$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
ethernets:
enp2s0:
dhcp4: false
addresses: [192.168.1.1/24]
nameservers:
addresses: [217.0.43.65, 217.237.149.225]
search: []
enp3s0:
dhcp4: true
(C)调查结果/调查:
我看过这些东西,但无济于事
https://askubuntu.com/questions/1083390/netplan-apply-does-not-change-the-ip-address
https://netplan.io/troubleshooting
netplan 似乎已经生成了我想要的东西:
:~$ cat /run/systemd/network/10-netplan-enp2s0.network
[Match]
Name=enp2s0
[Network]
LinkLocalAddressing=ipv6
Address=192.168.1.1/24
DNS=217.0.43.65
DNS=217.237.149.225
注意生成的输出——有什么明显的吗?
:~$ sudo netplan --debug generate
DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:2523): DEBUG: 10:24:20.181: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:2523): DEBUG: 10:24:20.182: starting new processing pass
** (generate:2523): DEBUG: 10:24:20.182: enp3s0: setting default backend to 1
** (generate:2523): DEBUG: 10:24:20.182: Configuration is valid
** (generate:2523): DEBUG: 10:24:20.182: enp2s0: setting default backend to 1
** (generate:2523): DEBUG: 10:24:20.182: Configuration is valid
** (generate:2523): DEBUG: 10:24:20.182: Generating output files..
** (generate:2523): DEBUG: 10:24:20.182: NetworkManager: definition enp2s0 is not for us (backend 1)
** (generate:2523): DEBUG: 10:24:20.182: NetworkManager: definition enp3s0 is not for us (backend 1)
请看一下这些输出,它们似乎带有唯一的提示:
:~$ sudo netplan --debug apply
** (generate:2528): DEBUG: 10:25:18.755: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:2528): DEBUG: 10:25:18.755: starting new processing pass
** (generate:2528): DEBUG: 10:25:18.755: enp3s0: setting default backend to 1
** (generate:2528): DEBUG: 10:25:18.755: Configuration is valid
** (generate:2528): DEBUG: 10:25:18.755: enp2s0: setting default backend to 1
** (generate:2528): DEBUG: 10:25:18.755: Configuration is valid
** (generate:2528): DEBUG: 10:25:18.755: Generating output files..
** (generate:2528): DEBUG: 10:25:18.755: NetworkManager: definition enp2s0 is not for us (backend 1)
** (generate:2528): DEBUG: 10:25:18.755: NetworkManager: definition enp3s0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:enp2s0 not found in {}
DEBUG:enp3s0 not found in {'enp2s0': {'dhcp4': False, 'addresses': ['192.168.1.1/24'], 'nameservers': {'addresses': ['217.0.43.65', '217.237.149.225'], 'search': []}}}
DEBUG:Merged config:
network:
bonds: {}
bridges: {}
ethernets:
enp2s0:
addresses:
- 192.168.1.1/24
dhcp4: false
nameservers:
addresses:
- 217.0.43.65
- 217.237.149.225
search: []
enp3s0:
dhcp4: true
vlans: {}
wifis: {}
DEBUG:Skipping non-physical interface: lo
DEBUG:device enp3s0 operstate is up, not changing
DEBUG:Skipping non-physical interface: wlp1s0
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp2s0
DEBUG:netplan triggering .link rules for enp3s0
DEBUG:netplan triggering .link rules for wlp1s0
请注意,它首先显示“netplan 生成的网络配置已更改...”,但下一行显示“不存在 netplan 生成的 NM 配置”。听起来好像某些网络配置仍处于活动状态?
此外,应用程序级别(语法已接受)似乎存在一些问题,yaml:enp2s0 not found in {},也位于其下一行。但为什么呢?
提前谢谢了 !