Centos 7 ip網路指令
Displays info about all network interfaces
ip a
ip addr
### Only show TCP/IP IPv4 ##
ip -4 a
### Only show TCP/IP IPv6 ###
ip -6 a
### Only show eth0 interface ###
ip a show eth0
ip a list eth0
ip a show dev eth0
### Only show running interfaces ###
ip link ls up
指定網卡IP
ip a add {ip_addr/mask} dev {interface}
ip a add 192.168.1.200/255.255.255.0 dev eth0
ip a add 192.168.1.200/24 dev eth0
增加網卡BROADCAST
ip addr add brd {ADDDRESS-HERE} dev {interface}
ip addr add broadcast {ADDDRESS-HERE} dev {interface}
ip addr add broadcast 172.20.10.255 dev dummy0
ip addr add 192.168.1.50/24 brd + dev eth0 label eth0Home
ip addr add 127.0.0.1/8 dev lo brd + scope host
刪除網卡ip
ip a del {ipv6_addr_OR_ipv4_addr} dev {interface}
ip a del 192.168.1.200/24 dev eth0
更新網卡ip
ip -s -s a f to 192.168.2.0/24
ip -4 addr flush label "ppp*"
ip -4 addr flush label "eth*"
指定網卡啟動、停止
ip link set dev {DEVICE} {up|down}
ip link set dev eth1 down
ip link set dev eth1 up
ip route: Routing table management commands
Show routing table
ip r
ip r list
ip r list [options]
ip route
增加 route
ip route add {NETWORK/MASK} via {GATEWAYIP}
ip route add {NETWORK/MASK} dev {DEVICE}
ip route add default {NETWORK/MASK} dev {DEVICE}
ip route add default {NETWORK/MASK} via {GATEWAYIP}
ip route add 192.168.1.0/24 via 192.168.1.254
ip route add 192.168.1.0/24 dev eth0
刪除 route
ip route del default
ip route del 192.168.1.0/24 dev eth0
參考:
Linux ip Command Examples