Linux中命令添加路由
第一種
#route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254 dev eth0/*
增加一條網(wǎng)絡(luò)192.168.1.0/24 的路由,網(wǎng)關(guān)是192.168.1.254,出接口是 eth0或eth0.211(子接口)
說(shuō)明:
-net:到網(wǎng)絡(luò)
netmask:到指定網(wǎng)絡(luò)的掩碼
gw:網(wǎng)關(guān),就是到指定網(wǎng)絡(luò)的下一跳
dev:出設(shè)備的接口,即到指定網(wǎng)絡(luò)的數(shù)據(jù)是從設(shè)備上的哪一個(gè)接口或子接口出去,通常該接口的IP 跟gw 是在同一個(gè)網(wǎng)段
第二種
使用 ip route 命令
ip route add 172.16.6.0/24 via 172.16.2.254 dev eth0
添加到網(wǎng)絡(luò) 172.16.6.0/24 的路由,出口為172.16.2.254(eth0)
ip route del gw 172.16.2.254 刪除到 172.16.2.254 默認(rèn)路由
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 添加默認(rèn)路由:
route add default gw 10.0.0.1 刪除默認(rèn)路由:
route del default gw 10.0.0.1 INUCE
轉(zhuǎn)載于:https://blog.51cto.com/4467001/1308331
總結(jié)
以上是生活随笔為你收集整理的Linux中命令添加路由的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Quality Center Issue
- 下一篇: 如果拿到私钥的话,https会被攻击吗?