Linux下實現不同網段之間訪問


linux系統管理員在工作的時候經常會遇到各種不一樣的問題,比如linux需要設置不同網段訪問問題,
對於很多新手們來說都是感覺非常的有難度,那么我們現在就去看看Linux下實現不同網段之間訪問的方法吧。
本實例要說明的是:實現10.0.0.0/24網段與192.168.2.0/24網段相互訪問.
步驟1:查看本機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:添加路由規則
[root@localhost root]# route add -net 192.168.2.0/24 eth0
步驟3:查看路由規則
[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
注:route規則中,必須同時存在兩個網段,否則,一個網段的IP地址將無法訪問到另一網段的IP地址。
步驟4:檢測本地機(IP:10.0.0.120)與遠程機(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:刪除路由規則
[root@localhost root]# route del -net 192.168.2.0/24 eth0
上文內容就是小編為大家介紹Linux下實現不同網段之間訪問的方法,看完后你了解了嗎?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM