標籤:路由器 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命令應用