Debian
Debian 11 上的持久靜態路由
我正在嘗試建立一個測試實驗室,如下所示:
PD:不是 Metasploit,而是 Metasploitable。
我正在執行 VirtualBox,路由器是 2 個執行 Debian 11 的虛擬機。每個路由器有 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
對於路由器 1169.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
對於路由器 2169.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.
journalctl -u networking.service
輸出:
cat /etc/network/interfaces
對於路由器 1:然後,如果我嘗試重新啟動系統,則在啟動時會引發錯誤“啟動失敗引發網路介面”
所以這就是我迷路的地方。有任何想法嗎?提前致謝。
您有 2 個向上命令。將其更改為
post-up ip route add... post-down ip route del...
並重新啟動網路服務或重新啟動