/etc/network/interfaces 包含以下内容:
source-directory /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
auto eth0
iface eth0 inet dhcp
我有一个板载以太网适配器,我想将其设置为 DHCP,还有一个 USB 转以太网适配器,我想将其设置为 192.168.1.10
如果启动时未插入 USB 适配器,我会收到 eth0 的 IP。
如果在启动时插入 USB 适配器,则 eth1 会获得静态 IP 192.168.1.10,但 eth0 不会获得 DHCP IPv4 地址
我已经花了好几天的时间在这上面,任何帮助我都会很感激。
编辑1:这是应用 grep 的 /var/log/syslog 输出(grep -E "dhclient|eth0|eth1")
启动时插入了 USB 转以太网适配器(没有为 eth0 分配 DHCP 地址)。syslog 输出:
Mar 6 12:12:36 jetson kernel: [ 2.154873] r8152 2-1.3:1.0 eth0: v2.09.00 (2017/08/21)
Mar 6 12:12:36 jetson kernel: [ 2.154878] r8152 2-1.3:1.0 eth0: This product is covered by one or more of the following patents:
Mar 6 12:12:38 jetson systemd[1]: Started ifup for eth1.
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4103] guessed connection type (eth1) = 802-3-ethernet
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4104] update_connection_setting_from_if_block: name:eth1, type:802-3-ethernet, id:Ifupdown (eth1), uuid: 7b635ed6-2640-7ad8-675d-744db12dd9fa
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4109] adding eth1 to connections
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4109] adding iface eth1 to eni_ifaces
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4129] devices added (path: /sys/devices/1003000.pcie/pci0000:00/0000:00:02.0/0000:01:00.0/net/eth1, iface: eth1)
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4133] devices added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0)
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4133] device added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0): no ifupdown configuration found.
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.4994] keyfile: new connection /run/NetworkManager/system-connections/netplan-eth0.nmconnection (75a1216a-9d1a-30cd-8aca-ace5526ec021,"netplan-eth0")
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.5210] dhcp-init: Using DHCP client 'dhclient'
Mar 6 12:12:38 jetson kernel: [ 5.348192] eth1: 0xffffff800d589000, 48:b0:2d:5c:39:cd, IRQ 407
Mar 6 12:12:38 jetson avahi-daemon[4207]: Joining mDNS multicast group on interface eth1.IPv4 with address 192.168.1.10.
Mar 6 12:12:38 jetson avahi-daemon[4207]: New relevant interface eth1.IPv4 for mDNS.
Mar 6 12:12:38 jetson avahi-daemon[4207]: Registering new address record for 192.168.1.10 on eth1.IPv4.
Mar 6 12:12:38 jetson kernel: [ 5.451629] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.6964] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/3)
Mar 6 12:12:38 jetson NetworkManager[4189]: <info> [1678133558.7150] manager: (eth1): new Ethernet device (/org/freedesktop/NetworkManager/Devices/4)
Mar 6 12:12:39 jetson networkd-dispatcher[4254]: ERROR:Unknown state for interface NetworkctlListState(idx=3, name='eth0', type='ether', operational='n/a', administrative='unmanaged'): n/a
Mar 6 12:12:39 jetson networkd-dispatcher[4254]: ERROR:Unknown state for interface NetworkctlListState(idx=4, name='eth1', type='ether', operational='n/a', administrative='unmanaged'): n/a
Mar 6 12:12:39 jetson NetworkManager[4189]: <info> [1678133559.3797] devices added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0)
Mar 6 12:12:39 jetson NetworkManager[4189]: <info> [1678133559.3798] device added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0): no ifupdown configuration found.
Mar 6 12:12:39 jetson NetworkManager[4189]: <info> [1678133559.3813] device (eth0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Mar 6 12:12:39 jetson kernel: [ 6.159876] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Mar 6 12:12:39 jetson kernel: [ 6.176569] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Mar 6 12:12:42 jetson NetworkManager[4189]: <info> [1678133562.7772] device (eth1): carrier: link connected
Mar 6 12:12:42 jetson kernel: [ 9.554106] r8168: eth1: link up
Mar 6 12:12:42 jetson kernel: [ 9.554147] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
Mar 6 12:12:43 jetson avahi-daemon[4207]: Joining mDNS multicast group on interface eth1.IPv6 with address fe80::4ab0:2dff:fe5c:39cd.
Mar 6 12:12:43 jetson avahi-daemon[4207]: New relevant interface eth1.IPv6 for mDNS.
Mar 6 12:12:43 jetson avahi-daemon[4207]: Registering new address record for fe80::4ab0:2dff:fe5c:39cd on eth1.*.
编辑2:
这是我的 netplan 配置
network:
ethernets:
eth0:
match:
macaddress: my_mac_for_onboard_ethernet
dhcp4: true
eth1:
dhcp4: false
addresses: [192.168.1.10/24]
version: 2
编辑3 这是我更新的 yaml 文件 - 目前 eth0 上没有 DHCP 地址
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
eth1:
addresses:
- 192.168.1.10/24
gateway4: 192.168.1.1