舉例說明Linux不同網段訪問的設定辦法

來源:互聯網
上載者:User
文章目錄
  •  
 

http://os.51cto.com  2010-03-04 15:00  佚名  互連網  我要評論(0)
  • 摘要:Linux不同網段訪問是一個有可能用的著的技術,Linux管理員應該瞭解這一技術,以便在需要時可以很快的設定起來,完成訪問的需求。
  • 標籤:Linux不同網段訪問

Linux管理員在工作時有可能會遇到各種各樣的問題,如需要設定Linux不同網段訪問這個工作,乍一聽起來還是有點難度的。本執行個體通過說明:實現10.0.0.0/24網段與192.168.2.0/24網段相互訪問.幫你明白這一個問題解決方式。

Linux不同網段訪問設定步驟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

Linux不同網段訪問設定步驟2:添加路由規則
[root@localhost root]# route add -net 192.168.2.0/24 eth0

Linux不同網段訪問設定步驟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地址。

Linux不同網段訪問設定步驟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

Linux不同網段訪問設定步驟5:刪除路由規則
[root@localhost root]# route del -net 192.168.2.0/24 eth0

可以在啟動指令碼中加入路由資訊route add -net 192.168.2.0/24 eth0

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.