通过 route 命令查看 Linux 内核的路由表:
lbrd@lbrd-PC:~$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 100 0 0 enp5s0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp5s0
lbrd@lbrd-PC:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp5s0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp5s0
lbrd@lbrd-PC:~$
局域网跨网段,需要设置路由,不然是访问不了的
命令:route add -net 192.168.1.0/24 gw 192.68.3.253
在需要路由的设备上,ssh登录后台执行 route add xxxxxxxx gw xxxxxxxxxx 命令,t添加局域网路由
参考文献:
1.Linux 路由表详解及 route 命令详解
2.linux route命令的使用详解