우분투 20.04 입니다.
systemd-networkd를 중지하고 비활성화했습니다. 그런 다음 NetworkManager를 활성화합니다. 그러나 다시 시작한 후에 두 서비스가 모두 나타납니다. 이것은 끊임없이 발생합니다. nmcli를 사용하여 서버를 관리하고 싶지만 작동 방법(및 네트워킹 중지)을 잘 모르겠습니다.
349 systemctl stop systemd-networkd
350 nmcli dev status
351 systemctl restart network-manager
352 systemctl status network-manager
364 systemctl status systemd-networkd
365 systemctl disable systemd-networkd
366 systemctl status NetworkManager
367 systemctl enable NetworkManager
---다시 시작한 후----
# ls -ltr /run/network/
total 4
-rw-r--r-- 1 root root 88 Feb 3 21:50 dynamic-interfaces
# nmcli dev status
DEVICE TYPE STATE CONNECTION
eno1 ethernet unmanaged --
eno2 ethernet unmanaged --
eno3 ethernet unmanaged --
eno4 ethernet unmanaged --
enp129s0f0 ethernet unmanaged --
enp129s0f1 ethernet unmanaged --
enp131s0f0 ethernet unmanaged --
enp131s0f1 ethernet unmanaged --
enp3s0f0 ethernet unmanaged --
enp3s0f1 ethernet unmanaged --
idrac ethernet unmanaged --
lo loopback unmanaged --
이제 DHCP를 사용하여 eno1의 네트워크에서 호스트로 SSH를 통해 연결할 수 있지만 나중에 이를 정적으로 만들고 싶습니다.
# 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
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
inet x.x.x.x/24 brd x.x.x.x scope global dynamic eno1
valid_lft 28733sec preferred_lft 28733sec
3: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
4: eno3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
5: eno4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
6: enp3s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
7: enp129s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
8: enp3s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
9: enp129s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
10: enp131s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
11: enp131s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
12: idrac: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
root@myhost:~#
root@myhost:~# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled-runtime; vendor preset: enabled)
Active: active (running) since Fri 2023-02-03 21:51:06 UTC; 8min ago
Docs: man:systemd-networkd.service(8)
Main PID: 1611 (systemd-network)
Status: "Processing requests..."
Tasks: 1 (limit: 309305)
Memory: 4.1M
CGroup: /system.slice/systemd-networkd.service
└─1611 /lib/systemd/systemd-networkd
Feb 03 21:51:06 myhost systemd[1]: Starting Network Service...
Feb 03 21:51:06 myhost systemd-networkd[1611]: Enumeration completed
Feb 03 21:51:06 myhost systemd[1]: Started Network Service.
Feb 03 21:51:06 myhost systemd-networkd[1611]: eno1: Link UP
Feb 03 21:51:07 myhost systemd-networkd[1611]: eno1: Gained carrier
Feb 03 21:51:07 myhost systemd-networkd[1611]: eno1: DHCPv4 address x.x.x.x/24 via x.x.x.x
root@myhost:~#
root@myhost:~# systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-02-03 21:51:10 UTC; 8min ago
Docs: man:NetworkManager(8)
Main PID: 1639 (NetworkManager)
Tasks: 3 (limit: 309305)
Memory: 14.9M
CGroup: /system.slice/NetworkManager.service
└─1639 /usr/sbin/NetworkManager --no-daemon
Feb 03 21:51:10 myhost NetworkManager[1639]: <info> [1675461070.5034] manager: (enp3s0f1): new Ethernet device (/or>
Feb 03 21:51:10 myhost NetworkManager[1639]: <info> [1675461070.5050] manager: (idrac): new Ethernet device (/org/f>
Feb 03 21:51:10 myhost NetworkManager[1639]: <warn> [1675461070.5286] Error: failed to open /run/network/ifstate
Feb 03 21:51:10 myhost NetworkManager[1639]: <info> [1675461070.5634] manager: startup complete
Feb 03 21:51:10 myhost NetworkManager[1639]: <info> [1675461070.8076] modem-manager: ModemManager not available
Feb 03 21:51:10 myhost NetworkManager[1639]: <info> [1675461070.8842] modem-manager: ModemManager now available
Feb 03 21:52:43 myhost NetworkManager[1639]: <info> [1675461163.2859] manager: rfkill: Wi-Fi hardware radio set dis>
Feb 03 21:52:43 myhost NetworkManager[1639]: <info> [1675461163.2862] audit: op="radio-control" arg="wireless-enabl>
Feb 03 21:58:03 myhost NetworkManager[1639]: <info> [1675461483.8856] manager: rfkill: WWAN hardware radio set disa>
Feb 03 21:58:03 myhost NetworkManager[1639]: <info> [1675461483.8858] audit: op="radio-control" arg="wwan-enabled" >
root@myhost:~#
그 이후로 나는 이렇게 했습니다:
지금까지 내가 이해한 가장 좋은 방법은 이 파일을 수정하는 것입니다.
# cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity' (<----from cloud-init of live dvd install....)
network:
ethernets:
eno1:
addresses: [x.x.x.x/24]
gateway4: x.x.x.x
nameservers:
addresses: [xx.x.x.x]
version: 2
# netplan apply
# nmcli c s
# nmcli d s
DEVICE TYPE STATE CONNECTION
eno1 ethernet unmanaged --
eno2 ethernet unmanaged --
eno3 ethernet unmanaged --
eno4 ethernet unmanaged --
enp129s0f0 ethernet unmanaged --
enp129s0f1 ethernet unmanaged --
enp131s0f0 ethernet unmanaged --
enp131s0f1 ethernet unmanaged --
enp3s0f0 ethernet unmanaged --
enp3s0f1 ethernet unmanaged --
idrac ethernet unmanaged --
lo loopback unmanaged --
#
IP 주소는 이제 정적이지만 nmcli는 여전히 이를 관리할 수 없으며 라우팅 테이블이 변경된 것 같습니다.
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 24:6e:96:06:f2:f8 brd ff:ff:ff:ff:ff:ff
inet x.x.x.x/24 brd x.x.x.x scope global eno1
valid_lft forever preferred_lft forever
systemd-networkd를 중지한 다음 netplan apply를 실행하면 오류가 발생합니다.
# systemctl stop systemd-networkd
# netplan apply
Failed to reload network settings: No such file or directory
Falling back to a hard restart of systemd-networkd.service
그런 다음 귀하의 제안을 시도했습니다.
# systemctl stop systemd-networkd
# systemctl disable systemd-networkd
# systemctl mask systemd-networkd
Created symlink /etc/systemd/system/systemd-networkd.service → /dev/null.
# systemctl restart NetworkManager
이제 완전히 미쳤습니다.
# netplan apply
Failed to reload network settings: No such file or directory
Falling back to a hard restart of systemd-networkd.service
Failed to restart systemd-networkd.service: Unit systemd-networkd.service is masked.
Traceback (most recent call last):
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 265, in command_apply
utils.networkctl_reload()
File "/usr/share/netplan/netplan/cli/utils.py", line 103, in networkctl_reload
subprocess.check_call(['networkctl', 'reload'])
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['networkctl', 'reload']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
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 247, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 61, in run
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 247, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 275, in command_apply
utils.systemctl('restart', ['systemd-networkd.service'], sync=True)
File "/usr/share/netplan/netplan/cli/utils.py", line 89, in systemctl
subprocess.check_call(command)
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'restart', 'systemd-networkd.service']' returned non-zero exit status 1.
nmcli/NetworkManager를 제외한 모든 것을 더 이상 사용하지 않으려고 했습니다. 이것은 너무 복잡해지고 있습니다.
답변1
정상적으로 실행
systemctl disable foo.service
[Install]
유닛 파일의 일부만 실행 취소합니다 . 다른 시스템 단위의 요구 사항이나 종속성을 통해 계속 실행될 수 있습니다.
서비스 실행을 중지하려면 다음을 실행해야 합니다.
systemctl mask foo.service
그러면 /etc의 /dev/null에 대한 심볼릭 링크로 유닛 파일을 덮어쓰므로 실행되지 않습니다.
답변2
Netplan 구성에 렌더러 지시문을 추가하고 문제를 해결했습니다. 이제 네트워크 마스크를 사용할 수 있습니다. 네트워크 관리자를 다시 시작하십시오. 이제 모든 것이 나노미터 미만입니다.
답변3
직접 언급했듯이 해결책은 렌더러를 netplan 구성 파일에 추가하는 것입니다. 그 이유는 다음 문서에 따르면 netplan에서 사용하는 기본 렌더러가 systemd-networkd이기 때문입니다. https://netplan.io/reference
배포 설치 프로그램, 클라우드 인스턴스화, 특정 장치에 대한 이미지 빌드 또는 기타 운영 체제 배포 방법은 필수 네트워크 구성을 YAML 구성 파일에 넣습니다. 초기 부팅 중에 /{lib,etc,run}/netplan/*.yaml을 읽고 /run에 구성을 쓰는 netplan "네트워크 렌더러"가 실행되어 장치 제어권을 지정된 네트워크 데몬 프로세스로 전송합니다.
- 구성된 장치는 특정 렌더러(NetworkManager)에 의해 관리되는 것으로 명시적으로 표시되지 않는 한 기본적으로 systemd-networkd에 의해 처리됩니다.