ip command cheat sheet
I really do think that ip is a big improvement from ifconfig , route , ifup , ifdown , and the other commands it replaces. Still I seem to have trouble remembering which commands you need to use the word “dev” and which ones you don’t and similar minor semantic issues (like parameter ordering). So I decided to try and compile a list of commands I commonly use to be used as a reference for studying.
I’m going to use eth0 as the device for these examples so just replace that with the interface to manipulate.
link
- ip link - show link info for all interfaces
- ip link show up - show link info for interfaces that are “up”
- ip link show eth0 show link info for eth0
- ip link set eth0 up - use instead of ifup (though not entirely equivalent)
- ip link set eth0 down - use instead of ifdown (though not entirely equivalent)
- ip link set eth0 promisc on - turn on promiscuous mode
- ip link set eth0 promisc off - turn off promiscuous mode
- ip link set eth0 txqlen 1000 - set txqueuelen (can also use “txqueuelen”)
- ip link set eth0 mtu 1500 - set mtu
addr
- ip addr - show addr info for all interfaces
- ip link show up - show addr info for interfaces that are “up”
- ip link show eth0 show addr info for eth0
- ip addr add 10.10.10.10/32 dev eth0 - add ip address and subnet to eth0
- also works: ip addr add dev eth0 10.10.10.10/32
- ip addr del 10.10.10.10/32 dev eth0 - remove ip address and subnet from eth0
- also works: ip addr del dev eth0 10.10.10.10/32
- ip addr flush dev eth0 - remove all addresses from eth0
route
- ip route - list all routes
- ip route flush - clear routing table
- The rest of the route commands are outside the scope of this page. But here are the basic commands for managing routes without the required parameters.
- ip route add - add a new route
- ip route change - change an existing route
- ip route replace - change route if it exists, add if it does not
- ip route del - delete route (without parameters this will delete the default route)
Related Posts
Tags: , command line tools, ip command