首页 > 代码库 > linux 不同网段相互访问
linux 不同网段相互访问
[root@Anonymous 桌面]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.96 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe1e:84b5 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:1e:84:b5 txqueuelen 1000 (Ethernet)
RX packets 2148 bytes 148398 (144.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 133 bytes 10790 (10.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 9 bytes 764 (764.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9 bytes 764 (764.0 B)
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:1d:99:a5 txqueuelen 0 (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@Anonymous 桌面]# 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 eno16777736
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
255.255.255.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736
[root@Anonymous 桌面]# route add -net 192.168.0.0 netmask 255.255.255.0 dev eno16777736
# 添加路由规则
[root@Anonymous 桌面]# 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 eno16777736
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eno16777736
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
255.255.255.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736
[root@Anonymous 桌面]#
linux 不同网段相互访问