buntu 18.04を実行していますが、ネットプラン構成が突然機能しなくなりました。走ると
Sudo netplan apply
次のメッセージが表示され、接続が失われます
Traceback (most recent call last):
File "/usr/sbin/netplan", line 23, in <module>
netplan.main()
File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 43, in run
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 106, in command_apply
stderr=subprocess.DEVNULL)
File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['udevadm', 'test-builtin', 'net_setup_link', '/sys/class/net/br0']' returned non-zero exit status 4.
私の設定ファイル
01-network-manager-all.yaml
以下は:
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp6s0:
dhcp4: no
# addresses: [192.168.2.6/24]
# gateway4: 192.168.2.1
# nameservers:
# addresses: [192.168.2.1]
match:
macaddress: 70:85:C2:43:68:6D
wakeonlan: true
dhcp6: no
bridges:
br0:
interfaces: [enp6s0]
dhcp4: no
addresses: [192.168.2.6/24]
gateway4: 192.168.2.1
nameservers:
addresses: [192.168.2.1]
誰かが同じ問題を抱えていますか?
自分で実行したときの最後のコマンドの出力は次のとおりです。
calling: test-builtin
Load module index
Parsed configuration file /lib/systemd/network/99-default.link
Parsed configuration file /run/systemd/network/10-netplan-enp6s0.link
Created link configuration context.
ID_NET_DRIVER=bridge
Config file /lib/systemd/network/99-default.link applies to device br0
link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
ID_NET_LINK_FILE=/lib/systemd/network/99-default.link
Unload module index
Unloaded link configuration context.
の出力
Sudo netplan --debug apply
以下は:
** (generate:15678): DEBUG: 17:00:44.797: Processing input file /etc/netplan/01-network-manager-all.yaml..
** (generate:15678): DEBUG: 17:00:44.797: starting new processing pass
** (generate:15678): DEBUG: 17:00:44.797: br0: setting default backend to 2
** (generate:15678): DEBUG: 17:00:44.797: Configuration is valid
** (generate:15678): DEBUG: 17:00:44.797: enp6s0: setting default backend to 2
** (generate:15678): DEBUG: 17:00:44.797: Configuration is valid
** (generate:15678): DEBUG: 17:00:44.797: Generating output files..
** (generate:15678): DEBUG: 17:00:44.797: networkd: definition enp6s0 is not for us (backend 2)
** (generate:15678): DEBUG: 17:00:44.797: networkd: definition br0 is not for us (backend 2)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:netplan generated NM configuration changed, restarting NM
DEBUG:enp6s0 not found in {}
DEBUG:br0 not found in {}
DEBUG:Merged config:
network:
bonds: {}
bridges:
br0:
addresses:
- 192.168.2.6/24
dhcp4: false
gateway4: 192.168.2.1
interfaces:
- enp6s0
nameservers:
addresses:
- 192.168.2.1
ethernets:
enp6s0:
dhcp4: false
dhcp6: false
match:
macaddress: 70:85:C2:43:68:6D
wakeonlan: true
vlans: {}
wifis: {}
DEBUG:Skipping non-physical interface: lo
DEBUG:Skipping composite member enp6s0
DEBUG:Skipping non-physical interface: virbr1
DEBUG:Skipping non-physical interface: virbr1-nic
DEBUG:Skipping non-physical interface: virbr2
DEBUG:Skipping non-physical interface: virbr2-nic
DEBUG:Skipping non-physical interface: virbr0
DEBUG:Skipping non-physical interface: virbr0-nic
DEBUG:Skipping non-physical interface: br0
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp6s0
DEBUG:netplan triggering .link rules for virbr1
DEBUG:netplan triggering .link rules for virbr1-nic
DEBUG:netplan triggering .link rules for virbr2
DEBUG:netplan triggering .link rules for virbr2-nic
DEBUG:netplan triggering .link rules for virbr0
DEBUG:netplan triggering .link rules for virbr0-nic
DEBUG:netplan triggering .link rules for br0
Traceback (most recent call last):
File "/usr/sbin/netplan", line 23, in <module>
netplan.main()
File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 43, in run
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 106, in command_apply
stderr=subprocess.DEVNULL)
File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['udevadm', 'test-builtin', 'net_setup_link', '/sys/class/net/br0']' returned non-zero exit status 4.
あなたのエラーは_netplan apply
_のNetworkManager固有のコードのバグが原因であると確信しています。
バグを修正するために、このブロック全体を端末に貼り付けることで適用できる簡単なパッチを作成しました。
_Sudo patch /usr/share/netplan/netplan/cli/commands/apply.py << EOF
--- /usr/share/netplan/netplan/cli/commands/apply.original.py
+++ /usr/share/netplan/netplan/cli/commands/apply.py
@@ -99,11 +99,14 @@
# if the interface is up, we can still apply some .link file changes
for device in devices:
logging.debug('netplan triggering .link rules for %s', device)
- subprocess.check_call(['udevadm', 'test-builtin',
- 'net_setup_link',
- '/sys/class/net/' + device],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL)
+ try:
+ subprocess.check_call(['udevadm', 'test-builtin',
+ 'net_setup_link',
+ '/sys/class/net/' + device],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL)
+ except subprocess.CalledProcessError:
+ logging.debug('Ignoring device without syspath: %s', device)
# apply renames to "down" devices
for iface, settings in changes.items():
EOF
_
それが完了すると、_Sudo netplan --debug apply
_コマンドは、他のすべての実行ではなく、すべての実行に成功するはずです。
これは一時的な修正であり、_netplan.io
_が更新された場合に元に戻されることに注意してください。恒久的な修正については、 Launchpadバグ#181004 に従ってください。
NetworkManagerレンダラーを使用する場合、NetplanApply.command_apply()
のロジックはnmcli
に、以前にnetifaces.interfaces()
によって入力されたデバイスを切断するように指示します。
_# restarting NM does not cause new config to be applied, need to shut down devices first
for device in devices:
# ignore failures here -- some/many devices might not be managed by NM
try:
utils.nmcli(['device', 'disconnect', device])
except subprocess.CalledProcessError:
pass
utils.systemctl_network_manager('stop', sync=sync)
_
これは、devices = netifaces.interfaces()
によって以前に設定されたdevices
変数が、_nmcli device disconnect
_の実行後に実際に存在するよりも多くのデバイスで古くなっている可能性があることを意味します。
このパッチは、_/sys/class/net/
_の後に欠落しているデバイスまたはデバイスエイリアス(_nmcli device disconnect
_には表示されない)を許容することでこのバグを修正し、次の_udevadm test-builtin net_setup_link /sys/class/net/XXX
_が残りのデバイスで機能するようにします。
_for device in devices:
logging.debug('netplan triggering .link rules for %s', device)
subprocess.check_call(['udevadm', 'test-builtin',
'net_setup_link',
'/sys/class/net/' + device],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
_
CanonicalLtd/netplan#86 にパッチをマージするように要求しました。