net-tools 與 iproute2 對照表
啊呀呀!CentOS 7 開始預設不安裝 net-tools 了,但對 towns 來說,這個實在是比較習慣,雖然說 iproutes 功能強大,但不會用還是沒有用,不會管理則是更槽的問題,不過,該學的還是得學啦!先做個對照表,其他新功能再寫到下面
查看指定網路列面資訊
net-tools:
ifconfig eth0
iproute2:
ip -s link show eth0 + ip -s add show eth0
啟動、停用網路介面
net-tools:
ifconfig eth0 up
ifconfig eth0 down
iproute2:
ip link set dev eth0 up
ip link set eth0 down
手動指定、移除 IP
net-tools:
ifconfig eth0 192.168.1.1/24
ifconfig eth0 0
iproute2:
ip addr add 192.168.1.1/24 dev eth0
ip addr del 192.168.1.1/24 dev eth0
子網卡設定
net-tools:
ifconfig eth0:0 192.168.1.10/24 up
ifconfig eth0:1 192.168.1.11/24 up
iproute2:
ip addr add 192.168.1.10/24 dev eth0
ip addr add 192.168.1.11/24 dev eth0
補充:ifconfig 建立的是一張虛擬介面卡,而 ip addr add 則是加入 aliases ip
加入\刪除 IPv6 資訊
net-tools:
ifconfig eth0 inet6 add 2002:0db5:0:f102::1/64
ifconfig eth0 inet6 add 2003:0db5:0:f102::1/64
ifconfig eth0 inet6 del 2002:0db5:0:f102::1/64
ifconfig eth0 inet6 del 2003:0db5:0:f102::1/64
iproute2:
ip -6 addr add 2002:0db5:0:f102::1/64
ip -6 addr add 2003:0db5:0:f102::1/64
ip -6 addr add 2002:0db5:0:f102::1/64
ip -6 addr add 2003:0db5:0:f102::1/64
變更網卡的 MAC
net-tools:
ifconfig eth0 hw ether 08:00:27:75:2a:66
iproute2:
ip line set dev eth0 address 08:00:27:75:2a:66
查看路由表
net-tools:
route -n
ifconfig -rn
iproute2:
ip route show
新增或變更預設路由
net-tools:
route add default gw 192.168.1.1 eth0
route del default gw 192.168.1.1 eth0
iproute2:
ip route add default gw 192.168.1.1 dev eth0
ip route replace default gw 192.168.1.1 dev eth0
新增或移除靜態路由
net-tools:
route add -net 192.168.2.0/24 gw 192.168.2.1 dev eth0
route del -net 192.168.2.0/24
iproute2:
ip route add 192.168.2.0/24 via 192.168.2.1 dev eth0
ip route del 192.168.2.0/24
查看 Socket 狀態
net-tools:
netstat
netstat -tulnp
iproute2:
ss
ss -tulnp
查看 ARP 表
net-tools:
arp -an
iproute2:
ip neigh
加入或移除靜態 ARP
net-tools:
arp -s 192.168.1.1 06:05:04:03:02:01
arp -d 192.168.1.1
iproute2:
ip neigh add 192.168.1.102 lladdr 06:05:04:03:02:01 dev eth0
ip neigh del 192.168.1.102 dev eth0
參考資料:Dan Nanni 大的文章
http://xmodulo.com/linux-tcpip-networking-net-tools-iproute2.html
留言
張貼留言