systemd-networkd.service 및 network.service는 새로 설치 시 재부팅 시 교대로 활성화됩니다.

systemd-networkd.service 및 network.service는 새로 설치 시 재부팅 시 교대로 활성화됩니다.

Debian Buster 템플릿에 LEMP 웹 서버를 설치했습니다.서버 공급자OVH.

서버에 연결 문제가 있었습니다. 때때로 핑이 손실된 후 OVH 기술자가 하드 재부팅을 요구했습니다.

운영 체제 템플릿 다시 설치세 번 처음부터 시작하세요. 나프로세서 및 메모리 테스트 실행결과는 괜찮습니다. 나파일 시스템 검사 실행. OVH 지원은 초과 구독되어 사용할 수 없습니다.지난 주 데이터 센터를 파괴한 화재로 인해... 그래서 거기에서 어떤 정보도 얻을 수 없습니다.

systemd-networkd.service그러다가 깨달았고networking.service 또는 재부팅 시 활성화됨. 다음은 기계 출력의 몇 가지 예입니다.

어제 하드 재부팅하기 전에는 여전히 SSH에 연결되어 있었습니다.

   root@srv:~# systemctl | grep network
      cloud-init-local.service  loaded active exited    Initial cloud-init job (pre-networking)                                      
    ● networking.service        loaded failed failed    Raise network interfaces                                                     
      network-online.target     loaded active active    Network is Online                                                            
      network-pre.target        loaded active active    Network (Pre)                                                                
      network.target            loaded active active    Network

root@srv:~# systemctl status networking.service 
    ● networking.service - Raise network interfaces
       Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Mon 2021-03-15 10:32:32 CET; 2h 24min ago
         Docs: man:interfaces(5)
      Process: 710 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
     Main PID: 710 (code=exited, status=1/FAILURE)
    
    Mar 15 10:32:31 srv dhclient[747]: DHCPREQUEST for 111.222.333.213 on enp3s0f0 to 255.255.255.255 port 67
    Mar 15 10:32:31 srv dhclient[747]: DHCPACK of 111.222.333.213 from 111.222.333.253
    Mar 15 10:32:32 srv ifup[710]: /etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /etc/resolvconf/run/resolv.conf
    Mar 15 10:32:32 srv dhclient[747]: bound to 111.222.333.213 -- renewal in 40762 seconds.
    Mar 15 10:32:32 srv ifup[710]: bound to 111.222.333.213 -- renewal in 40762 seconds.
    Mar 15 10:32:32 srv ifup[710]: RTNETLINK answers: File exists
    Mar 15 10:32:32 srv ifup[710]: ifup: failed to bring up enp3s0f0
    Mar 15 10:32:32 srv systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
    Mar 15 10:32:32 srv systemd[1]: networking.service: Failed with result 'exit-code'.
    Mar 15 10:32:32 srv systemd[1]: Failed to start Raise network interfaces.

어제 하드 재부팅 후:

root@srv:/etc/systemd/network# systemctl | grep network
cloud-init-local.service                                                                                         loaded active exited    Initial cloud-init job (pre-networking)                                      
networking.service                                                                                               loaded active exited    Raise network interfaces                                                     
network-online.target                                                                                            loaded active active    Network is Online                                                            
network-pre.target                                                                                               loaded active active    Network (Pre)                                                                
network.target                                                                                                   loaded active active    Network


root@srv:/etc/systemd/network# systemctl status networking.service 
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: active (exited) since Tue 2021-03-16 13:53:25 CET; 1 day 1h ago
     Docs: man:interfaces(5)
 Main PID: 714 (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   Memory: 14.3M
   CGroup: /system.slice/networking.service
           └─751 /sbin/dhclient -4 -v -i -pf /run/dhclient.enp3s0f0.pid -lf /var/lib/dhcp/dhclient.enp3s0f0.leases -I -df /var/lib/dhcp/dhclient6.enp3s0f0.leases enp3s0f0

root@srv:/etc/systemd/network# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
   Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:systemd-networkd.service(8)

네트워크 구성

root@srv:~# ls /etc/network/
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  interfaces.d

root@srv:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

# The normal eth0
allow-hotplug eth0
iface eth0 inet dhcp

# Additional interfaces, just in case we're using multiple networks
allow-hotplug eth1
iface eth1 inet dhcp

allow-hotplug eth2
iface eth2 inet dhcp

# Set this one last, so that cloud-init or user can defaults.
source /etc/network/interfaces.d/*

root@srv:~# ls /etc/network/interfaces.d/
50-cloud-init

root@srv:~# cat /etc/network/interfaces.d/50-cloud-init      
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  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}
auto lo
iface lo inet loopback

auto enp3s0f0
iface enp3s0f0 inet dhcp
    accept_ra 0

# control-alias enp3s0f0
iface enp3s0f0 inet6 static
    address 2001:abcd:1007:efgh::/56
    dns-nameservers 2001:abcd:3:163::1
    gateway 2001:abcd:1007:1dff:ff:ff:ff:ff
    post-up route add -A inet6 2001:abcd:1007:ef00::/57 gw 2001:abcd:1007:1dff:ff:ff:ff:ff || true
    pre-down route del -A inet6 2001:abcd:1007:ef00::/57 gw 2001:abcd:1007:1dff:ff:ff:ff:ff || true

[... plus about fifty similar lines ...]

root@srv:~# ls /etc/systemd/network

root@srv:~# ls /lib/systemd/network
80-container-host0.network  80-container-ve.network  80-container-vz.network  99-default.link

질문

  1. 이 구성에 연결이 자주 끊어지는 원인이 있나요?

  2. 항상 동일한 서비스(systemd.networkd 또는 네트워킹)로 다시 시작하도록 하려면 어떻게 해야 합니까?

  3. 정글의 어느 곳에 고정 IP를 추가하나요?

파일에 다음을 추가할 수 있지만 /etc/systemd/network/(현재 비어 있음) 이는 systemd.networkd를 시작하고 다른 것을 중지하려고 시도한다는 것을 의미합니다. 원격 SSH에서 이 작업을 수행할 수 있는지 확실하지 않습니다... 서비스가 올바르게 설정되어 있다면!

nano /etc/systemd/network/50-default.network

[Address]
Address=FAILOVER_IP/32
Label=failover1 # optional

아니면 그런 것을 추가 /etc/network/interfaces하고 다시 시작하는 것이 더 낫습니까 networking.service?

auto eth0:0
iface eth0:0 inet static
address STATIC_IP
netmask 255.255.255.255

auto eth0:1
iface eth0:1 inet static
address OTHER_STATIC_IP
netmask 255.255.255.255

감사합니다!

참고로 모든 네트워크 구성은 OVH의 템플릿에서 제공되지만 안타깝게도 해당 주제에 대한 지식은 매우 제한적입니다. 또한 연속적인 데비안 릴리스 간의 네트워크 구성 변경으로 인해 IMHO 학습이 더욱 어려워졌습니다.

답변1

성 내에서만 /etc/network/interfaces:

#source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback

바라보다5.3. GUI가 없는 최신 네트워크 구성정적 또는 DHCP 네트워크 구성을 구성합니다. 예를 들어:

/etc/systemd/network/10-dhcp-enp3s0f0.network:

[Match]
Name=enp3s0f0

[Network]
DHCP=yes

/etc/systemd/network/10-static-eth0-0.network:

[Match]
Name=eth0:0

[Network]
Address=STATIC_IP
Gateway=gatway_here
DNS=dns_here

경고가 있습니다:

    Mar 15 10:32:32 srv ifup[710]: /etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /etc/resolvconf/run/resolv.conf

이 문제는 다음을 통해 해결될 수 있습니다.

ln -s  /etc/resolvconf/run/resolv.conf /etc/resolv.conf

아치리눅스 위키:시스템 네트워크

데비안 위키:시스템 네트워크

답변2

이 문제를 처리하는 현대적인 방법인 것 같으므로 @GAD3R의 답변을 허용된 것으로 표시합니다.

그러나 결국 이전 설정을 고수하고 고정 IP에 대해 다음 구성을 enp3s0f0사용하여 파일 을 추가했습니다./etc/network/interfaces.d

auto enp3s0f0:1
iface enp3s0f0:1 inet static
address aaa.bb.cc.232/29

auto enp3s0f0:2
iface enp3s0f0:2 inet static
address aaa.bb.cc.233/29

auto enp3s0f0:3
iface enp3s0f0:3 inet static
address aaa.bb.cc.234/29

[...]

그런 다음 다시 시작하십시오 networking.service.

마지막으로 누락된 심볼릭 링크를 수정하는 것으로 ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf충분한지 확실하지 않지만 며칠 전에 재부팅했고 더 이상 네트워크 문제를 해결하려고 노력하지 않습니다.

관련 정보