11 linux suse 本地源_suse 11 Linux 静态路由的添加方法
系統(tǒng):suse 11 Linux
版本:SUSE Linux Enterprise Server 11 (i586)
VERSION = 11
PATCHLEVEL = 0
簡單介紹一下配置文件方式添加靜態(tài)路由的方法
配置文件路徑:vim /etc/sysconfig/network/routes
按以下格式添加內(nèi)容:
192.168.1.200 192.168.1.1 255.255.255.0 eth2????????? 這是我的36機(jī)器,使用了3塊網(wǎng)卡,每個(gè)網(wǎng)卡的路由配置如下
10.166.173.36 10.166.173.11 255.255.255.0 eth0
10.10.53.85 10.10.53.81 255.255.255.240 eth1
default 10.166.173.11 - -?????????????????????????????????????????????????? ?? 指定“缺省路由”,其實(shí)表示3個(gè)路由中是優(yōu)先級(jí)最高的1個(gè)
字段解釋
192.168.1.200--->表示本地網(wǎng)卡ip地址(有host or subnetwork之分)
192.168.1.1--->表示網(wǎng)關(guān)(下一跳IP)
255.255.255.0--->表示子網(wǎng)掩碼(subnetwork) )
eth1--->表示給哪塊網(wǎng)卡配路由
default 10.166.173.11 - -? 默認(rèn)網(wǎng)關(guān)(缺省路由),也就是你一共配置了3個(gè)路由,缺省路由優(yōu)先級(jí)最高
特點(diǎn):執(zhí)行/etc/init.d/network restart命令讓配置生效 或者 service network restart? 重新加載網(wǎng)絡(luò)配置,都要使用root用戶
注意在編輯時(shí),不要有空行,不然會(huì)出錯(cuò)了.
在配置文件中這樣添加靜態(tài)路由后,主機(jī)重啟路由配置會(huì)自動(dòng)加載,就不用每次手動(dòng)添加路由了
幾種查看路由的命令:
(1)ip route?? ip與路由映射關(guān)系
10.10.53.80/28 dev eth1? proto kernel? scope link? src 10.10.53.85
10.166.173.0/24 dev eth0? proto kernel? scope link? src 10.166.173.36
192.168.1.0/24 dev eth2? proto kernel? scope link? src 192.168.1.200
169.254.0.0/16 dev eth0? scope link
127.0.0.0/8 dev lo? scope link
default via 10.166.173.11 dev eth0
(2)route????? 內(nèi)核路由表
Kernel IP routing table
Destination???? Gateway???????? Genmask???????? Flags Metric Ref??? Use Iface
10.10.53.80???? ? *?????????????? 255.255.255.240??? U???? 0????? 0??????? 0 eth1
10.166.173.0?? ? *?????????????? 255.255.255.0????? ? U???? 0????? 0??????? 0 eth0
192.168.1.0????? ?*?????????????? 255.255.255.0?????? ?U???? 0????? 0??????? 0 eth2
link-local????????? ? *?????????????? 255.255.0.0??????????? ?U???? 0????? 0??????? 0 eth0
loopback????????? ? *?????????????? 255.0.0.0??????????????? ? U???? 0????? 0??????? 0 lo
default???????? 10.166.173.11?? 0.0.0.0????????????? ? UG??? 0????? 0??????? 0 eth0
(3)route -n?? 已數(shù)字方式顯示路由表
Kernel IP routing table
Destination???? Gateway???????? Genmask???????? Flags Metric Ref??? Use Iface
10.10.53.80???? 0.0.0.0???????? 255.255.255.240 U???? 0????? 0??????? 0 eth1
10.166.173.0??? 0.0.0.0???????? 255.255.255.0?? U???? 0????? 0??????? 0 eth0
192.168.1.0???? 0.0.0.0???????? 255.255.255.0?? U???? 0????? 0??????? 0 eth2
169.254.0.0???? 0.0.0.0???????? 255.255.0.0???? U???? 0????? 0??????? 0 eth0
127.0.0.0?????? 0.0.0.0???????? 255.0.0.0?????? U???? 0????? 0??????? 0 lo
0.0.0.0???????? 10.166.173.11?? 0.0.0.0???????? UG??? 0????? 0??????? 0 eth0
(4) netstat -rn?? 人性化顯示路由表
Kernel IP routing table
Destination???? Gateway???????? Genmask???????? Flags?? MSS Window? irtt Iface
10.10.53.80???? 0.0.0.0???????? 255.255.255.240 U???????? 0 0????????? 0 eth1
10.166.173.0??? 0.0.0.0???????? 255.255.255.0?? U???????? 0 0????????? 0 eth0
192.168.1.0???? 0.0.0.0???????? 255.255.255.0?? U???????? 0 0????????? 0 eth2
169.254.0.0???? 0.0.0.0???????? 255.255.0.0???? U???????? 0 0????????? 0 eth0
127.0.0.0?????? 0.0.0.0???????? 255.0.0.0?????? U???????? 0 0????????? 0 lo
0.0.0.0???????? 10.166.173.11?? 0.0.0.0???????? UG??????? 0 0????????? 0 eth0
實(shí)例:
數(shù)據(jù)包轉(zhuǎn)發(fā)
132.0.0.0/255.0.0.0? gw set to 10.166.173.16?? 從這個(gè)41采集機(jī)上把發(fā)送到132.0.0.0這個(gè)網(wǎng)段上的數(shù)據(jù)都指向10.166.173.16地址
添加/刪除靜態(tài)路由
命令方式
route add -net 10.10.54.0 netmask 255.255.255.240 gw 10.10.53.81? 把發(fā)送到目的地10.10.54.0網(wǎng)段的數(shù)據(jù)包,先轉(zhuǎn)發(fā)到10.10.53.81這個(gè)下一跳
route add -net 10.10.54.0 netmask 255.255.255.0 gw 10.10.53.81??? 添加路由
route del -net 10.10.54.0 netmask 255.255.255.240 gw 10.10.53.81? 把發(fā)送到目的地10.10.54.0網(wǎng)段的數(shù)據(jù)包,先轉(zhuǎn)發(fā)到10.10.53.81這個(gè)下一跳
route del -net 10.10.54.0 netmask 255.255.255.0 gw 10.10.53.81??? 刪除路由
配置文件:vim /etc/sysconfig/network/routes?? 以#開始的行是注釋,每一行是一個(gè)路由記錄,由空格分隔的多列組成
192.168.1.200 192.168.1.1 255.255.255.0 eth2
10.166.173.36 10.166.173.11 255.255.255.0 eth0
10.10.53.85 10.10.53.81 255.255.255.240 eth1
10.10.54.0 10.10.53.81 255.255.255.0 eth1
default 10.166.173.11 - -
2012.03.19
leonarding
tianjin
總結(jié)
以上是生活随笔為你收集整理的11 linux suse 本地源_suse 11 Linux 静态路由的添加方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极速写作2017彻底卸载_如何将 Fla
- 下一篇: linux 其他常用命令