systemd Ubuntu를 사용하여 시작 시 고정 경로를 가질 수 없습니다.

systemd Ubuntu를 사용하여 시작 시 고정 경로를 가질 수 없습니다.

VMWare Fusion VM에서 실행되는 Ubuntu 18.04.4 LTS를 사용하고 있으며 부팅 시 정적 경로를 추가해야 합니다.

  1. 로컬 인터페이스( )에 할당된 IP 중 하나와 동일한 네트워크에 있는 192.168.11.0/24IP를 통해 접속 가능한 네트워크로 .192.168.10.4eth0

  2. 로컬 인터페이스( )에 할당된 IP 중 하나와 동일한 네트워크에 있는 192.168.2.0/24IP를 통해 접속 가능한 네트워크로192.168.122.101virbr0

10-static.network이를 구현하기 위해 네트워크 파일을 다음과 같이 구성했습니다.

root@gns3local:~# cat /etc/systemd/network/10-static.network
[Route]
Gateway=192.168.10.5
Destination=192.168.11.0/24
root@gns3local:~# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.10.1    0.0.0.0         UG        0 0          0 eth0
192.168.10.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.10.1    0.0.0.0         255.255.255.255 UH        0 0          0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
root@gns3local:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.5  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::250:56ff:fe3e:70a6  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:3e:70:a6  txqueuelen 1000  (Ethernet)
        RX packets 234  bytes 22886 (22.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 156  bytes 22033 (22.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:01:a3:e5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


root@gns3local:~# 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 Mon 2020-07-27 16:52:47 UTC; 12min ago
     Docs: man:systemd-networkd.service(8)
 Main PID: 515 (systemd-network)
   Status: "Processing requests..."
    Tasks: 1 (limit: 5861)
   CGroup: /system.slice/systemd-networkd.service
           └─515 /lib/systemd/systemd-networkd

Jul 27 16:52:47 gns3local systemd-networkd[515]: virbr0-nic: Lost carrier
Jul 27 16:52:47 gns3local systemd-networkd[515]: virbr0-nic: Removing non-existent address: fe80::5054:ff:fe01:a3e5/64
Jul 27 16:52:48 gns3local systemd-networkd[515]: eth0: Gained IPv6LL
Jul 27 16:52:48 gns3local systemd-networkd[515]: eth0: Configured

이제 시스템이 다시 시작된 후 경로가 추가되지 않으며 이와 관련된 오류도 없습니다.

root@gns3local:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.5  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::250:56ff:fe3e:70a6  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:3e:70:a6  txqueuelen 1000  (Ethernet)
        RX packets 83  bytes 12321 (12.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 77  bytes 11639 (11.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:01:a3:e5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
root@gns3local:~# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.10.1    0.0.0.0         UG        0 0          0 eth0
192.168.10.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.10.1    0.0.0.0         255.255.255.255 UH        0 0          0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
root@gns3local:~# 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 Mon 2020-07-27 17:39:02 UTC; 2min 22s ago
     Docs: man:systemd-networkd.service(8)
 Main PID: 539 (systemd-network)
   Status: "Processing requests..."
    Tasks: 1 (limit: 5860)
   CGroup: /system.slice/systemd-networkd.service
           └─539 /lib/systemd/systemd-networkd

Jul 27 17:39:02 gns3local systemd-networkd[539]: virbr0-nic: Could not set route: Network is unreachable
Jul 27 17:39:02 gns3local systemd-networkd[539]: virbr0: Link UP
Jul 27 17:39:02 gns3local systemd-networkd[539]: virbr0-nic: Link DOWN
Jul 27 17:39:02 gns3local systemd-networkd[539]: virbr0-nic: Lost carrier
Jul 27 17:39:02 gns3local systemd-networkd[539]: virbr0-nic: Removing non-existent address: fe80::5054:ff:fe01:a3e5/64
Jul 27 17:39:03 gns3local systemd-networkd[539]: eth0: DHCPv4 address 192.168.10.5/24 via 192.168.10.1
Jul 27 17:39:03 gns3local systemd-networkd[539]: eth0: Gained IPv6LL
Jul 27 17:39:03 gns3local systemd-networkd[539]: eth0: Configured

질문:

  • 시작 시 경로가 유지되지 않는 이유는 무엇일까요?

  • 시작 시 고정 경로를 추가하는 가장 좋은 방법은 무엇입니까?

  • 동일한 경로 추가를 사용하는 방법은 무엇입니까 crontab?

관련 정보