Linux中命令添加路由
第一種
#route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254 dev eth0/*
增加一條網(wǎng)絡192.168.1.0/24 的路由,網(wǎng)關是192.168.1.254,出接口是 eth0或eth0.211(子接口)
說明:
-net:到網(wǎng)絡
netmask:到指定網(wǎng)絡的掩碼
gw:網(wǎng)關,就是到指定網(wǎng)絡的下一跳
dev:出設備的接口,即到指定網(wǎng)絡的數(shù)據(jù)是從設備上的哪一個接口或子接口出去,通常該接口的IP 跟gw 是在同一個網(wǎng)段
第二種
使用 ip route 命令
ip route add 172.16.6.0/24 via 172.16.2.254 dev eth0
添加到網(wǎng)絡 172.16.6.0/24 的路由,出口為172.16.2.254(eth0)
ip route del gw 172.16.2.254 刪除到 172.16.2.254 默認路由
ip route del 172.16.6.0/24 dev eth0 刪除到172.16.6.0/24 的路由
ip route 刪除的方法:添加路由:
route add -net 10.0.0.0 netmask 255.0.0.0 dev eth0 刪除路由:
route del -net 10.0.0.0 netmask 255.0.0.0 dev eth0 添加默認路由:
route add default gw 10.0.0.1 刪除默認路由:
route del default gw 10.0.0.1 INUCE
轉(zhuǎn)載于:https://blog.51cto.com/4467001/1308331
總結(jié)
以上是生活随笔為你收集整理的Linux中命令添加路由的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Quality Center Issue
- 下一篇: 老生常谈.优化linux内核参数