Several of the most used Linux commands/tools such as ifconfig, netstat, route is deprecated. It’s time to start using the versatile ip command line utility.
Ip command line utility provided by the ‘net-tools’ package is used for various network administration tasks on Linux nodes.
Syntax of the ip command line utility:
# ip [ OPTIONS ] OBJECT { COMMAND | help}
OPTIONS are used to define global parameters. Commonly used ones being:
-4 -> shows IPv4 specific details only.
-6 -> shows IPv6 specific details only.
-s -> shows statistics of the various network interfaces.
-t -> display current time when using monitor option.
OBJECTS are the items the command would action on.
Commonly used OBJECTS are the follows:
OBJECT |
Abbreviation |
Used for |
address |
a, addr |
IP address on the device |
link |
l |
Network device |
route |
r |
Routing table entry |
rule |
ru |
Rule in the routing policy database |
neighbour |
n, neigh |
Manage ARP/NDSC cache entries |
maddress |
m, maddr |
Multicast address |
monitor |
|
Watch netlink messages |
This cheat sheet offers a concise overview of the ip
command and its available options. It serves as a
valuable resource for troubleshooting network and system issues."
NOTE: The commands have certain parameters mentioned in capital letters like ‘INTERFACE’, this needs to be changed depending on your use case.
1. Displaying Network Information:
- ip address show or ip a : Show information about all network interfaces.
- ip link show or ip l : Display link layer information.
- ip route show or ip r : Display the routing table.
2. Managing Network Interfaces:
- ip link set dev INTERFACE up/down : Enable or disable a network interface.
- ip link set dev INTERFACE name NEW_NAME : Rename a network interface.
- ip link set dev INTERFACE mtu MTU_VALUE : Set the Maximum Transmission Unit (MTU) for an interface.
- ip link add link INTERFACE name NEW_INTERFACE type TYPE : Create a new virtual interface based on an existing one.
3. Configuring IP Addresses:
- ip address add IP_ADDRESS/NETMASK dev INTERFACE : Assign an IP address to an interface.
- ip address delete IP_ADDRESS/NETMASK dev INTERFACE : Remove an IP address from an interface.
- ip address show dev INTERFACE : Display IP address information for a specific interface.
4. Managing Routes:
- ip route add NETWORK via GATEWAY : Add a static route.
- ip route delete NETWORK : Delete a static route.
- ip route show : Display the routing table.
- ip route flush cache : Clear the routing cache.
5. Managing ARP Cache:
- ip neigh show : Display the ARP cache.
- ip neigh add IP_ADDRESS lladdr MAC_ADDRESS dev INTERFACE : Add an ARP cache entry manually.
- ip neigh delete IP_ADDRESS dev INTERFACE : Delete an entry from the ARP cache.
6. Managing VLANs (Virtual LANs):
- ip link add link INTERFACE name VLAN_NAME type vlan id VLAN_ID : Create a VLAN interface.
- ip link show VLAN_NAME : Display information about a VLAN interface.
7. Managing Bridge Interfaces:
- ip link add name BRIDGE_NAME type bridge : Create a bridge interface.
- ip link set dev INTERFACE master BRIDGE_NAME : Add an interface to a bridge.
- ip link set dev INTERFACE nomaster : Remove an interface from a bridge.
- ip link show BRIDGE_NAME : Display information about a bridge.
8. Managing Tunnels:
- ip tunnel add TUNNEL_NAME mode MODE remote REMOTE_IP local LOCAL_IP : Create a tunnel interface.
- ip tunnel delete TUNNEL_NAME : Delete a tunnel interface.
- ip tunnel show : Display information about tunnel interfaces.
9. Managing QoS and Traffic Control:
- ip link set dev INTERFACE qlen QUEUE_LENGTH : Set the length of the transmit queue.
- ip link set dev INTERFACE txqueuelen QUEUE_LENGTH : Set the length of the transmit queue.
- tc : Use the tc command for advanced traffic control and QoS configuration.
10. Managing Multicast:
- ip maddr show : Display multicast group memberships.
- ip maddr add IP_ADDRESS dev INTERFACE : This adds the INTERFACE to the membership of the multicast group with an IPv4 address of IP_ADDRESS.
- ip maddr delete IP_ADDRESS dev INTERFACE : Leave the INTERFACE from the multicast group with ip address IP_ADDRESS.
This ip command cheat sheet should provide you with a quick reference for managing network configurations and interfaces in Linux.
Remember to replace INTERFACE, IP_ADDRESS, NETMASK, NETWORK, GATEWAY, VLAN_NAME, BRIDGE_NAME, TUNNEL_NAME, REMOTE_IP, LOCAL_IP, QUEUE_LENGTH, and other placeholders with your specific values when using the commands.
No comments:
Post a Comment