Linux系統(tǒng)技巧:Linux中增加軟路由的兩種方法_Linux教程
Linux中增加軟路由的方法一:
route add -net 172.16.6.0 netmask 255.255.255.0 gw 172.16.2.254 dev eth0/*
增加一條網(wǎng)絡(luò)172.16.6.0/24 經(jīng)過(guò)172.16.2.254 eth0 *//* -net增加網(wǎng)絡(luò) -host增加主機(jī)、netmask 子網(wǎng)掩碼、gw 網(wǎng)關(guān)、dev 裝置,設(shè)備,這里是你的網(wǎng)卡名*/route del gw 172.16.2.254 /* 刪除默認(rèn)網(wǎng)關(guān)172.16.2.254 */route del -net 172.16.86.0/24 /* 刪除默認(rèn)網(wǎng)絡(luò)172.16.86.0 */route /* 顯示當(dāng)前路由表 */常用的是這種方式,但有時(shí)你在刪除或一條軟路由時(shí)會(huì)不起作用,會(huì)有什么提示:SIOCADDRT: 無(wú)法接觸網(wǎng)路,所以這時(shí)用如下的這種方法就可以了。
Linux中增加軟路由的方法二:
實(shí)現(xiàn)的功能和上面的一樣
ip route add 172.16.6.0/24 via 172.16.2.254 dev eth0 ip route del gw 172.16.2.254 ip route del 172.16.6.0/24 dev eth0ip 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
或者
以下是代碼片段:
route del default
linux下添加路由的方法:
使用 route 命令添加
使用route 命令添加的路由,機(jī)器重啟或者網(wǎng)卡重啟后路由就失效了,方法:
以下是代碼片段:
//添加到主機(jī)的路由
# route add –host 192.168.168.110 dev eth0
# route add –host 192.168.168.119 gw 192.168.168.1
//添加到網(wǎng)絡(luò)的路由
# route add –net IP netmask MASK eth0
# route add –net IP netmask MASK gw IP
# route add –net IP/24 eth1
//添加默認(rèn)網(wǎng)關(guān)
# route add default gw IP
//刪除路由
# route del –host 192.168.168.110 dev eth0
在linux下設(shè)置永久路由的方法:
1.在/etc/rc.local里添加
以下是代碼片段:
route add -net 192.168.3.0/24 dev eth0 route add -net 192.168.2.0/24 gw 192.168.3.254
2.在/etc/sysconfig/network里添加到末尾
方法:GATEWAY=gw-ip 或者 GATEWAY=gw-dev
3./etc/sysconfig/static-router :
以下是代碼片段:
any net x.x.x.x/24 gw y.y.y.y
Linux中增加軟路由的方法大家應(yīng)該能夠掌握和理解了,我們還會(huì)繼續(xù)整理相關(guān)內(nèi)容供大家參考的。
相關(guān)Linux教程:
- Linux系統(tǒng)下TOP命令使用與分析詳解
- 安裝Linux我們需要改變20件事情
- 使用Linux系統(tǒng)架設(shè)VSFTP服務(wù)器
- Linux系統(tǒng)上架設(shè)POP3服務(wù)器
- Linux中“Networking Disabled”的解決方法(解決Ubuntu等系統(tǒng)無(wú)法上網(wǎng))
- ubuntu系統(tǒng)清理磁盤教程
- linux下搭建pxe自動(dòng)化安裝環(huán)境
- BIOS不支持導(dǎo)致Linux內(nèi)核耗電增加
- Debian GNU/Linux系統(tǒng)卡片
- Linux操作系統(tǒng)開(kāi)機(jī)自行啟動(dòng)項(xiàng)目詳細(xì)解析
- Linux菜鳥(niǎo)入門級(jí)命令大全
- Linux操作系統(tǒng)中讀取目錄文件信息的過(guò)程
Linux教程Rss訂閱服務(wù)器教程搜索
Linux教程推薦
- linux下安裝配置svn獨(dú)立服務(wù)器的步驟分享
- Linux下清空用戶登錄記錄和命令歷史的方法
- 使用Linux系統(tǒng)架設(shè)VSFTP服務(wù)器
- Linux新手要了解的十個(gè)知識(shí)點(diǎn)
- Linux系統(tǒng)如何設(shè)置程序開(kāi)機(jī)自動(dòng)運(yùn)行
- Linux的基于PAM的用戶認(rèn)證
- Linux操作系統(tǒng)中七件超厲害的武器
- Linux系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡負(fù)載均衡
- 學(xué)習(xí)Linux不可就范的五個(gè)錯(cuò)誤
- linux如果忘記root密碼和grub密碼怎么辦
- 相關(guān)鏈接:
- 教程說(shuō)明:
Linux教程-Linux系統(tǒng)技巧:Linux中增加軟路由的兩種方法
。