2009年10月29日

網路相關指令複習

ifconfig
ifconfig eth0 up
啟動eth0
ifconfig eth0 down
關閉eth0
ifconfig eth0 192.168.100.100 netmask 255.255.255.0 mtu 800
設定ip
ifconfig eth0:0 192.168.200.2
增加一個邏輯上的網路介面

/etc/init.d/network restart將使用系統內在/etc/sysconfig/network-scripts的設定來設定網路卡
ifup eth0跟ifdown eth0是做類似的事情,但是如果已經使用ifconfig更改設定後,ifdown會無效

route
route -n
顯示routing table
route add default gw 192.168.10.30
設定default gateway
route add -net 167.254.0.0 netmask 255.255.0.0 dev eth0
增加一個routing path
route del -net 169.24.0.0 netmask 255.255.255.0 dev eth0
刪除一個routing path

netstate
netstate -rn
顯示出routing table
netstate -utlnp
u表示udp,t表示tcp,l表示listen,n表示不要進行dns,p表示port number

ip指令
功能強大的一個指令,可以完全取代ifconfig跟route,不過便利上來說不及。但是mac layer的資訊跟動作必須透過ip指令才能做細部的調整
ip adress show
幾乎等同ifconfig
ip link set eth0 down
等同ifdown eth0
ip link set eth0 up
等同ifup eth0
ip link set eth0 mtu 1000
同ifconfig eth0 mtu 1000,不過在設定的時候要先關閉eth0
ip route show
顯示routing table

ip link set eth0 address bb:bb:bb:bb:bb:bb
設定mac address
ip link set eth0 name hello
設定主機名稱

沒有留言: