Debian 11の継続的な静的ルーティング

Debian 11の継続的な静的ルーティング

次のテストラボを設定しようとしています。

PD: Metasploit ではなく Metasploitable です。

私はVirtualBoxを実行しており、ルーターはDebian 11を実行している2つの仮想マシンです。各ルーターには2つのインターフェースがあります。

~# ls /sys/class/net/
enp0s3    enp0s8    lo

~のためルーター1

~# cat /etc/network/interfaces
[...]
# The primary network interface
auto enp0s3
iface enp0s3 inet static
        address 192.168.10.254
        netmask 255.255.255.0
auto enp0s8
iface enp0s8 inet static
        address 192.168.100.1
        netmask 255.255.255.0

~のためルーター2

~# cat /etc/network/interfaces
[...]
# The primary network interface
auto enp0s3
iface enp0s3 inet static
        address 192.168.100.2
        netmask 255.255.255.0
auto enp0s8
iface enp0s8 inet static
        address 192.168.20.254
        netmask 255.255.255.0

パスを追加しようとしています。ルーター1そして

~# ip route add 192.168.20.0/24 via 192.168.100.2 dev enp0s8

そしてルーター2そして

~# ip route add 192.168.10.0/24 via 192.168.100.1 dev enp0s3

ip route show~のためルーター1

169.254.0.0/16 dev enp0s3 scope link metric 1000
192.168.10.0/24 dev enp0s3 proto kernel scope link src 192.168.10.254
192.168.20.0/24 via 192.168.100.2 dev enp0s8
192.168.100.0/24 dev enp0s8 proto kernel scope link src 192.168.100.1

ip route show~のためルーター2

169.254.0.0/16 dev enp0s3 scope link metric 1000
192.168.10.0/24 via 192.168.100.1 dev enp0s3
192.168.20.0/24 dev enp0s3 proto kernel scope link src 192.168.20.254
192.168.100.0/24 dev enp0s8 proto kernel scope link src 192.168.100.2

後でこのような変化が長続きしないことを知ってみてみました。

https://www.mybluelinux.com/debian-permanent-static-routes/

systemctl restart networkingネットワークサービスを再起動すると、または経由の出力は次の/etc/init.d/networking restartようになります。

Jobs for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journal -xe" for details.

systemctl status networking.service出力:

Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code)
Process: 478 ExecStart=/sbin/ifup -a --read-enviroment (code=exited, status=1/FAILURE)


router1 systemd[1]: Starting Raise network interfaces...
router1 ifup[499]: RTNETLINK answers: File existis
router1 ifup[478]: ifup: failed to bring up enp0s8
router1 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
router1 systemd[1]: networking.service: Failed with result 'exit-code'.
router1 systemd[1]: Failed to start Raise network interfaces.

journalctl -u networking.service出力:

--Boot blabla hash blabla
router1 systemd[1]: Starting Raise network interfaces...
router1 ifup[499]: RTNETLINK answers: No such process
router1 ifup[478]: ifup: failed to bring up enp0s8
router1 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
router1 systemd[1]: networking.service: Failed with result 'exit-code'.
router1 systemd[1]: Failed to start Raise network interfaces.
--Boot blabla other hash blabla
router1 systemd[1]: Starting Raise network interfaces...
router1 ifup[499]: RTNETLINK answers: File existis
router1 ifup[478]: ifup: failed to bring up enp0s8
router1 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
router1 systemd[1]: networking.service: Failed with result 'exit-code'.
router1 systemd[1]: Failed to start Raise network interfaces.

cat /etc/network/interfacesルーター1の場合:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet static
        address 192.168.10.254
        netmask 255.255.255.0
auto enp0s8
iface enp0s8 inet static
        address 192.168.100.1
        netmask 255.255.255.0
#       gateway 192.168.10.254
        up ip route del 192.168.20.0/24 via 192.168.100.2 dev enp0s8
        up ip route add 192.168.20.0/24 via 192.168.100.2 dev enp0s8

その後、システムを再起動しようとすると、起動時に「ネットワークインターフェイスを起動できませんでした」というエラーが発生します。

だからこれは私が迷子になった場所です。どんなアイデアがありますか?

ベストアンサー1

あなたは2を持っています戻る注文する。それに変える

post-up ip route add...
post-down ip route del...

ネットワークサービスを再起動または再起動してください。

おすすめ記事