Linux網絡管理常用命令:net-tools VS iproute2


Exported from workflowy!
  • net-tools vs iproute2
    • net-tools
      • ifconfig
        ifconfig命令:用於接口及地址查看和管理
      • route
      • netstat
      • arp
    • iproute2
      • ip link help
      • ip addr help
      • ip route help
      • ss
      • ip neigh
    • 顯示網卡接口信息
      • ifconfig -a
        - ifconfig 顯示已啟用的網卡信息
        - ifconfig -a:顯示所有接口,包括inactive狀態的接口
      • ifconfig eth0
        顯示eth0接口
      • ip link [show]
        顯示所有連接的網絡接口
      • ip link show dev eht0
        顯示eth0接口
    • 顯示網絡接口IP地址
      要是有多個IP地址分配給了某個接口,iproute2就會顯示所有IP地址,而net-tools只能顯示一個IP地址
      • ifconfig
      • ifconfig eht0
      • ip addr [show]
      • ip addr show dev eth0
        顯示網絡接口IPv4地址
      • ip -6 addr show dev eth0
        顯示網絡接口IPv6地址
    • 激活或禁止網絡接口
      • ifconfig eth0 up/down
      • ip link set up/down eth0
    • 網絡接口分配IPv4地址
      注意:如果使用iproute2,你可以將多個IP地址分配給某個接口;如果換成ifconfig,就無法做到這點。就ifconfig而言,一個變通辦法就是使用IP別名。
      • ifconfig eth0 192.168.10.10/24
      • ifconfig eth0 192.168.10.10 netmask 255.255.255.0
      • ip addr add 192.168.10.10/24 dev eth0
    • 網絡接口刪除IPv4地址
      • ifconfig eth0 0
      • ip addr del 192.168.10.10/24 dev eth0
    • 更改網絡接口的MAC地址
      • ifconfig eth0 hw ether 08:00:27:75:2a:66 
      • ip link set dev eth0 address 08:00:27:75:2a:67 
    • 查看IP路由表
      • route -n
      • netstat -rn
      • ip route [show]
    • 添加或修改默認路由
      下面這些命令可以添加或改動內核IP路由表中的默認路由。要注意:如果使用net-tools,只要添加一個新的默認路由,就可以實現改動默認路由這個操作。如果使用iproute2,只需使用ip route replace命令。
      • route add default gw 192.168.10.1 eth0
      • route del default gw 192.168.10.1 eth0 
      • ip route add default via 192.168.10.1 dev eth0  
      • ip route replace default via 192.168.10.1 dev eth0 
    • 添加或刪除靜態路由
      • route add -net 172.14.32.0/24 gw 192.168.1.1 dev eth0  
      • route del -net 172.14.32.0/24 
      • ip route add 172.14.32.0/24 via 192.168.1.1 dev eth0  
      • ip route del 172.14.32.0/24

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM