systemd Ubuntuを使用して起動時に固定パスを持つことはできません。

systemd Ubuntuを使用して起動時に固定パスを持つことはできません。

VMWare Fusion VMで実行されているUbuntu 18.04.4 LTSを使用しており、起動時に静的パスを追加する必要があります。

  1. ローカルインタフェース()に割り当てられたIPの1つと同じネットワーク上の192.168.11.0/24IPを介して接続可能なネットワーク。192.168.10.4eth0

  2. ローカルインタフェース()に割り当てられたIPの1つと同じネットワーク上の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

ベストアンサー1

おすすめ記事