1. ip命令
show / manipulate routing, devices, policy routing and tunnels
ip [ OPTIONS ] OBJECT { COMMAND | help }
OBJECT := { link | address | route}
1)link: network device.
list 用ip命令显示网络设备的运行状态
show [dev IFace]指定接口显示
[up]仅显示处于激活状态的接口
set dev IFACE 可设置属性的UP/DOWN
2) addr: (address)
- protocol (IP or IPv6) address on a device.
ip addr {add|del} IFADDR dev IFNAME
添加|删除 地址 设备名
ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ][ label LABEL ] [up]
flush:清空
[label LABEL] 添加地址时指明网卡别名
[ scope {global|link|host}] 指明作用域
global:全局有效(默认) link:仅链接有效 host:本机有效
IFADDR := [ broadcast ADDR ] 指明广播地址
ip address [ show [ dev IFNAME ] [ label LABEL ] [up] ]
3)route: routing table entry.
ip route { add | del } ROUTE
(1) ip route add
添加路由:ip route add TARGET via GW dev IFace src source_ip
TARGET: 主机路由 ip
网络路由 network/mask
添加网关:ip route add default via GW dev IFACE
(2) ip route delete
删除路由: ip route del TARGET
(3) ip route flush 清空
[dev IFACE]
原文地址:https://blog.51cto.com/12928116/2370179
时间: 2024-10-10 04:24:30