Linux下route命令應用

來源:互聯網
上載者:User

標籤:路由器   linux   

Linux之route命令詳解
理論:linux下預設如果不安裝相關包的情況下下 只支援靜態路由|根本不支援什麼rip協議 ospf、
如果有些大型項目中需要把linux做成路由器、需要開啟轉寄模式
###
LINUX#echo1>/proc/sys/net/ip_forward   註:0代表不轉寄  1代錶轉發
###

route常見參數:
            -n  :列出的資訊已IP來顯示(也就是看路由表)
     -add:增加路由
     -del:刪除路由
            netmask:目標網路的子網路遮罩
            -net:增加一個網域的路由
     gw  :指定本地網卡的網關
            dev :指定本地的網卡 也就是eth0 eth1
---------------------------------------------------------------------------------------------------
查看路由資訊
---------------------------------------------------------------------------------------------------
[[email protected] root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref  Use Iface
140.116.141.253 *               255.255.255.255 UH    0      0      0 ppp0
192.168.1.0     *               255.255.255.0   U     0      0      0 eth0
127.0.0.0       *               255.0.0.0       U     0      0      0 lo
default         140.116.141.253 0.0.0.0         UG    0      0      0 ppp0  //預設的網關


----------------------------------------------------------------------------------------------------
添加路由資訊 
----------------------------------------------------------------------------------------------------
route add -net 10.103.12.0 netmask 255.255.255.128 gw 10.100.86.49 dev eth0
----------------------------------------------------------------------------------------------------
刪除路由資訊 
----------------------------------------------------------------------------------------------------
route del -net 10.103.12.0 netmask 255.255.255.128 dev eth0

----------------------------------------------------------------------------------------------------
指定預設閘道 
----------------------------------------------------------------------------------------------------
route add default gw 192.168.1.2 

本文出自 “老韓技術筆記” 部落格,請務必保留此出處http://hzyan.blog.51cto.com/9617993/1579605

Linux下route命令應用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.