linux 访问不同网段
本實(shí)例要說(shuō)明的是:實(shí)現(xiàn)10.0.0.0/24網(wǎng)段與192.168.2.0/24網(wǎng)段相互訪問.
步驟1:查看本機(jī)IP地址
[root@localhost root]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:A7:6E:77
inet addr:10.0.0.120 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2418 errors:0 dropped:0 overruns:0 frame:0
TX packets:1293 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1000347 (976.9 Kb) TX bytes:192592 (188.0 Kb)
Interrupt:10 Base address:0x2024
步驟2:添加路由規(guī)則
[root@localhost root]# route add -net 192.168.2.0/24 eth0
或 [root@localhost root]# route add -net 192.168.0.0/24 gw 192.168.5.50
步驟3:查看路由規(guī)則
[root@localhost root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 * 255.255.255.0 U 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
步驟4:檢測(cè)本地機(jī)(IP:10.0.0.120)與遠(yuǎn)程機(jī)(IP:192.168.2.80)是否可互訪.
[root@localhost root]# ping 192.168.2.80
PING 192.168.2.80 (192.168.2.80) 56(84) bytes of data.
64 bytes from 192.168.2.80: icmp_seq=1 ttl=127 time=5.51 ms
64 bytes from 192.168.2.80: icmp_seq=2 ttl=127 time=3.17 ms
步驟5:刪除路由規(guī)則
[root@localhost root]# route del -net 192.168.2.0/24 eth0
B類IP地址:用14位來(lái)標(biāo)識(shí)網(wǎng)絡(luò)號(hào),16位標(biāo)識(shí)主機(jī)號(hào),前面兩位是”10”.B類地址的第一段取值介于128~191之間,第一段和第二段合在一起表示網(wǎng)絡(luò)號(hào)。B類地址適用于中等規(guī)模的網(wǎng)絡(luò),全世界大約有16000個(gè)B類網(wǎng)絡(luò),每個(gè)B類網(wǎng)絡(luò)最多可以連接65534臺(tái)主機(jī)。
C類IP地址:用21位來(lái)標(biāo)識(shí)網(wǎng)絡(luò)號(hào),8位標(biāo)識(shí)主機(jī)號(hào),前面三位是”110”.C類地址的第一段取值介于192~223之間,第一段、第二段、第三段合在一起表示網(wǎng)絡(luò)號(hào)。最后一段標(biāo)識(shí)網(wǎng)絡(luò)上的主機(jī)號(hào)。C類地址適用于校園網(wǎng)等小型網(wǎng)絡(luò),每個(gè)C類網(wǎng)絡(luò)最多可以有254臺(tái)主機(jī)。
總結(jié)
以上是生活随笔為你收集整理的linux 访问不同网段的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【linux家常菜】redhat 6.5
- 下一篇: 如何在 Linux 中使用 find