Home | Mirror | Search

3. iproute2

add 增加路由
del 刪除路由
via 網關出口 IP地址
dev 網關出口 物理設備名
		

3.1. 添加路由

ip route add 192.168.0.0/24 via 192.168.0.1
ip route add 192.168.1.1 dev 192.168.0.1			
			

3.2. 刪除路由

ip route del 192.168.0.0/24 via 192.168.0.1			
			

3.3. 變更路由

[root@router ~]# ip route
192.168.5.0/24 dev eth0  proto kernel  scope link  src 192.168.5.47
192.168.3.0/24 dev eth0  proto kernel  scope link  src 192.168.3.47
default via 192.168.3.1 dev eth0

[root@router ~]# ip route change default via 192.168.5.1 dev eth0

[root@router ~]# ip route list
192.168.5.0/24 dev eth0  proto kernel  scope link  src 192.168.5.47
192.168.3.0/24 dev eth0  proto kernel  scope link  src 192.168.3.47
default via 192.168.5.1 dev eth0
			

3.4. 替換已有的路由

 ip route replace
			

3.5. 增加預設路由

192.168.0.1 是我的預設路由器

ip route add default via 192.168.0.1 dev eth0
			

3.6. cache

ip route flush cache			
			
comments powered by Disqus