IP Command
View/Set routing, device, routing policy, and channel information
Format
IP [OPTIONS] OBJECT {COMMAND | help}
OBJECT: = {link | addr | addrlabel | route | rule | neigh | tunnel | maddr | mroute |
Monitor} # Object command, similar to an IP command subcommand
OPTIONS: = {-v[ersion] |-s[tatistics] |-r[esolve] |-f[amily] {inet | inet6 | ipx |
dnet | LINK} | -o[neline]}
Common options
-V View version
-S view more detailed content
-F enforces the use of the specified protocol family
-4 Specifies the use of the IPV4 protocol
-6 Specifies the use of the IPV6 protocol
-0 non-newline output information
-R using the host's domain name display host
Common Object Commands
IP link settings, viewing data link layer Information
IP addr View Set IP information
IP route View Set Routing information
To view object commands using methods
IP OBJECT Help
Example
1. View information for all network cards
[[Email protected] ~] #ip A # View all network card information1: Lo: <LOOPBACK,UP,LOWER_UP> MTU65536qdisc noqueue State UNKNOWN Link/loopbackxx:xx:xx:xx:xx:xxBrdxx:xx:xx:xx:xx:xxinet127.0.0.1/8Scope host lo inet6::1/ -Scope host Valid_lft forever Preferred_lft forever2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU theQdisc Pfifo_fast State up Qlen +...4: eth2: <BROADCAST,MULTICAST> MTU theQdisc NoOp State down Qlen +Link/etherxx: 0c: in:d 3: -: +BRD Ff:ff:ff:ff:ff:ff[[email protected]-PC ~] #ip a show eth2 # View network card eth2 information4: eth2: <BROADCAST,MULTICAST> MTU theQdisc NoOp State down Qlen +Link/etherxx: 0c: in:d 3: -: +BRD FF:FF:FF:FF:FF:FF
2. View Addr Object Command usage
[[Email protected] ~] #ip route help # | flush} SELECTOR IP route get ADDRESS [From address IIf STRING] [OIF string] [tos tos] | del | change | append | replace | monitor} routeselector: = [Root PREFIX] [match PREFIX] [exact PREFIX] [table table_id] [proto Rtproto] [Type type] [sc Ope SCOPE]route:= Node_spec [info_spec]node_spec:= [TYPE] PREFIX [tos tos] ...
3. Displaying routing information
[[Email protected] ~] #ip Route169.254.0.0/ -Dev eth0 Scope link metric1002 169.254.0.0/ -Dev eth1 Scope link metric1003 172.16.0.0/ -Dev eth0 proto kernel scope link src172.16.253.55 55.0.0.0/8Dev eth1 proto kernel scope link src55.0.0.55Default via55.0.0.1Dev eth1
4. Show routing information for the next hop or the router on the previous line
[[Email protected] ~] #ip neigh list 172.16. 253.209 Dev eth0 lladdr f0:1c:a9:8b:1b DELAY172.16. 0.1 Dev eth0 lladdr F8:+: e4:$ bf:a4 STALE 172.16. 252.15 Dev eth0 lladdr 1c:cd:e5:3e: STALE55.0. 0.1 Dev eth1 FAILED
5. Assigning IP address information
[[Email protected] ~] #ip addr Add172.100.100.100/ -Dev eth2 # assign ip[[email protected]-PC ~] #ip a show eth2 # view eth2 NIC Information4: eth2: <BROADCAST,MULTICAST> MTU theQdisc NoOp State down Qlen +Link/etherxx: 0c: in:d 3: -: +BRD ff:ff:ff:ff:ff:ff inet172.100.100.100/ -Scope Global Eth2
[[Email protected] ~] #ip addr del 172.100.100.100/16 dev eth2 # remove IP configuration
[[Email protected] ~] #ip addr Flush eth2 # Clear All IP configuration on the eth2 NIC
6. Modifying Routing information
[[Email protected] ~] #ip route add15.0.0.0/8Via172.16.0.1 # Add route record[[Email protected]-PC ~] #ip route # View the routing table169.254.0.0/ -Dev eth0 Scope link metric1002 169.254.0.0/ -Dev eth1 Scope link metric1003 172.16.0.0/ -Dev eth0 proto kernel scope link src172.16.253.55 55.0.0.0/8Dev eth1 proto kernel scope link src55.0.0.55 15.0.0.0/8Via172.16.0.1Dev eth0 # just added to default via55.0.0.1Dev eth1 [[email protected]-PC ~] #ip route del15.0.0.0/8# Delete routing records [[email protected]-PC ~] #route-N # Use the route command to view routing records kernel IP routing table Destination Gateway Genmask Flags Metric Ref use Iface169.254.0.0 0.0.0.0 255.255.0.0U1002 0 0eth0169.254.0.0 0.0.0.0 255.255.0.0U1003 0 0eth1172.16.0.0 0.0.0.0 255.255.0.0U0 0 0eth055.0.0.0 0.0.0.0 255.0.0.0U0 0 0eth10.0.0.0 55.0.0.1 0.0.0.0Ug0 0 0Eth1
Linux Network configuration commands (ii)--IP