问题:我无法在以太网端口上获取静态 IP。
目的:尝试在 Realtek 内置以太网 (enp3s0) 端口上设置静态 IP,以便我可以通过交叉电缆将服务器连接到我的桌面。目前,两者之间没有连接电缆。
设置:Ubuntu Bionic 服务器版配备英特尔 WiFi 卡和 Reaktek 以太网端口。安装过程中,我必须将以太网端口连接到调制解调器/路由器,因为 Ubuntu 安装程序无法识别我的 WiFi 卡。
我尝试过的事情:
我禁用了我的 WiFi 卡,然后尝试只使用“dchp4: true”,然后将电缆从端口连接到我的调制解调器/路由器。获取 IP 和 ping 站点没有问题。
我尝试过使用和不使用“renderer: networkd”,没有区别。
我尝试过使用和不使用“dhcp4”false,没有区别。
我尝试过使用和不使用gateway4,没有区别。
我尝试过使用和不使用名称服务器,没有区别。
sudo netplan --debug apply 没有显示任何错误
我查看了 /run/systemd/network 中生成的配置(包括在下面)并且看起来不错。
按照本页的建议调试 systemd-networkd (https://wiki.ubuntu.com/DebuggingSystemd),然后我可以看到这一行:“enp3s0:链接不由我们管理”。这似乎不对,因为我没有其他东西来管理我的接口,而且正如我在第一点中所说的,使用 DHCP 是可行的。
这是我当前的配置:
>cat /etc/netplan/01-wireless.yaml
network:
version: 2
renderer: networkd
wifis:
wlp2s0:
dhcp4: true
access-points:
"insert-access-point-here":
password: "insert-password-here"
>cat /etc/netplan/02-ethernet.yaml
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
addresses: [192.168.2.1/24]
gateway4: 192.168.2.254
>cat /run/systemd/network/10-netplan-wlp2s0.network
[Match]
Name=wlp2s0
[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
[DHCP]
UseMTU=true
RouteMetric=600
>cat /run/systemd/network/10-netplan-enp3s0.network
[Match]
Name=enp3s0
[Network]
LinkLocalAddressing=ipv6
Address=192.168.2.1/24
Gateway=192.168.2.254
netplan --debug apply 的结果
sudo netplan --debug apply
** (generate:13784): DEBUG: 03:16:37.754: Processing input file /etc/netplan/01-wireless.yaml..
** (generate:13784): DEBUG: 03:16:37.755: starting new processing pass
** (generate:13784): DEBUG: 03:16:37.755: wlp2s0: adding wifi AP 'myhotspot'
** (generate:13784): DEBUG: 03:16:37.755: Processing input file /etc/netplan/02-ethernet.yaml..
** (generate:13784): DEBUG: 03:16:37.755: starting new processing pass
** (generate:13784): DEBUG: 03:16:37.755: wlp2s0: setting default backend to 1
** (generate:13784): DEBUG: 03:16:37.755: enp3s0: setting default backend to 1
** (generate:13784): DEBUG: 03:16:37.755: Generating output files..
** (generate:13784): DEBUG: 03:16:37.755: wlp2s0: Creating wpa_supplicant configuration file run/netplan/wpa-wlp2s0.conf
** (generate:13784): DEBUG: 03:16:37.755: Creating wpa_supplicant service enablement link /run/systemd/system/multi-user.target.wants/[email protected]
** (generate:13784): DEBUG: 03:16:37.755: NetworkManager: definition wlp2s0 is not for us (backend 1)
** (generate:13784): DEBUG: 03:16:37.755: NetworkManager: definition enp3s0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration exists, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:wlp2s0 not found in {}
DEBUG:enp3s0 not found in {}
DEBUG:Merged config:
network:
bonds: {}
bridges: {}
ethernets:
enp3s0:
addresses:
- 192.168.2.1/24
gateway4: 192.168.2.254
vlans: {}
wifis:
wlp2s0:
access-points:
insert-access-point-here:
password: insert-password-here
dhcp4: true
DEBUG:Skipping non-physical interface: lo
DEBUG:device wlp2s0 operstate is up, not changing
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp3s0
DEBUG:netplan triggering .link rules for wlp2s0
systemd 网络调试结果:
>sudo SYSTEMD_LOG_LEVEL=debug /lib/systemd/systemd-networkd
Failed to read $container of PID 1, ignoring: Permission denied
Found container virtualization none.
Bus n/a: changing state UNSET → OPENING
Bus n/a: changing state OPENING → AUTHENTICATING
Failed to open configuration file '/etc/systemd/networkd.conf': No such file or directory
timestamp of '/etc/systemd/network' changed
timestamp of '/run/systemd/network' changed
Ignoring /run/systemd/network/10-netplan-enp3s0.network, because it's not a regular file with suffix .netdev.
Ignoring /run/systemd/network/10-netplan-wlp2s0.network, because it's not a regular file with suffix .netdev.
Ignoring /lib/systemd/network/99-default.link, because it's not a regular file with suffix .netdev.
Ignoring /lib/systemd/network/80-container-ve.network, because it's not a regular file with suffix .netdev.
Ignoring /lib/systemd/network/80-container-vz.network, because it's not a regular file with suffix .netdev.
Ignoring /lib/systemd/network/80-container-host0.network, because it's not a regular file with suffix .netdev.
Ignoring /lib/systemd/network/99-default.link, because it's not a regular file with suffix .network.
wlp2s0: Flags change: +UP +LOWER_UP +RUNNING +MULTICAST +BROADCAST
wlp2s0: Link 3 added
wlp2s0: udev initialized link
wlp2s0: Saved original MTU: 1500
enp3s0: Flags change: +UP +MULTICAST +BROADCAST
enp3s0: Link 2 added
enp3s0: udev initialized link
enp3s0: Saved original MTU: 1500
lo: Flags change: +LOOPBACK +UP +LOWER_UP +RUNNING
lo: Link 1 added
lo: udev initialized link
lo: Saved original MTU: 0
wlp2s0: Adding address: fe80::3613:e8ff:fe41:a078/64 (valid forever)
wlp2s0: Gained IPv6LL
lo: Adding address: ::1/128 (valid forever)
wlp2s0: Adding address: 192.168.1.2/24 (valid forever)
lo: Adding address: 127.0.0.1/8 (valid forever)
rtnl: received address with invalid family 129, ignoring
Enumeration completed
Bus n/a: changing state AUTHENTICATING → HELLO
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=2 reply_cookie=0 signature=su error-name=n/a error-message=n/a
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=3 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=4 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=5 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_31 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=6 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=7 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=8 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=9 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
wlp2s0: Link state is up-to-date
wlp2s0: found matching network '/run/systemd/network/10-netplan-wlp2s0.network'
enp3s0: Link is not managed by us
lo: Link is not managed by us
LLDP: Started LLDP client
wlp2s0: Started LLDP.
wlp2s0: Acquiring DHCPv4 lease
DHCP CLIENT (0x8f3ad0c0): STARTED on ifindex 3
wlp2s0: Discovering IPv6 routers
NDISC: Started IPv6 Router Solicitation client
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=10 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=11 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=12 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
NDISC: Sent Router Solicitation, next solicitation in 3s
Got message type=method_return sender=org.freedesktop.DBus destination=:1.12 path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=s error-name=n/a error-message=n/a
Bus n/a: changing state HELLO → RUNNING
DHCP CLIENT (0x8f3ad0c0): DISCOVER
Got message type=signal sender=org.freedesktop.DBus.Local destination=n/a path=/org/freedesktop/DBus/Local interface=org.freedesktop.DBus.Local member=Connected cookie=4294967295 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Got message type=signal sender=org.freedesktop.DBus destination=:1.12 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=2 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Got message type=signal sender=org.freedesktop.DBus destination=:1.12 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=3 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Got message type=method_return sender=org.freedesktop.DBus destination=:1.12 path=n/a interface=n/a member=n/a cookie=4 reply_cookie=2 signature=u error-name=n/a error-message=n/a
Successfully acquired requested service name.
Got message type=method_return sender=org.freedesktop.DBus destination=:1.12 path=n/a interface=n/a member=n/a cookie=5 reply_cookie=3 signature=n/a error-name=n/a error-message=n/a
Match type='signal',sender='org.freedesktop.login1',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager',member='PrepareForSleep' successfully installed.
enp3s0: Link state is up-to-date
enp3s0: found matching network '/run/systemd/network/10-netplan-enp3s0.network'
lo: Link is not managed by us
wlp2s0: Link does not request DHCPv6 prefix delegation
LLDP: Started LLDP client
enp3s0: Started LLDP.
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=13 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
lo: Link state is up-to-date
No virtualization found in DMI
No virtualization found in CPUID
Virtualization XEN not found, /proc/xen does not exist
This platform does not support /proc/device-tree
No virtualization found in /proc/cpuinfo.
This platform does not support /proc/sysinfo
Found VM virtualization none
lo: Unmanaged
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_31 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=14 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
wlp2s0: Removing address: 192.168.1.2/24 (valid forever)
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=15 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=16 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
DHCP CLIENT (0x8f3ad0c0): OFFER
DHCP CLIENT (0x8f3ad0c0): REQUEST (requesting)
DHCP CLIENT (0x8f3ad0c0): ACK
wlp2s0: DHCPv4 address 192.168.1.2/24 via 192.168.1.1
wlp2s0: Updating address: 192.168.1.2/24 (valid forever)
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=17 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=18 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
wlp2s0: DHCP error: could not get routes: No data available
wlp2s0: Configured
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=19 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
NDISC: Sent Router Solicitation, next solicitation in 7s
NDISC: Sent Router Solicitation, next solicitation in 14s
NDISC: No RA received before link confirmation timeout
NDISC: Invoking callback for 't'.