ip Linux Command Guide
The ip command in Linux is a versatile tool used to manage network configurations. It allows users to display, configure, and manage network interfaces, IP addresses, routes, and more. With ip, you can troubleshoot network issues, set up virtual interfaces, assign multiple IP addresses to a single interface, and manage routing tables effectively. This command replaces the older ifconfig and route commands, providing a more robust and modern solution for configuring network settings in Linux distributions.
ip Syntax:
Section titled “ip Syntax:”ip [options] [parameters]
Options:
Section titled “Options:”Option | Description |
---|---|
link | Network device-specific operations |
address | Address-specific operations |
route | Routing table-specific operations |
neighbor | Neighbor-specific operations |
-s | Display short output |
-h | Display help message |
Parameters:
Section titled “Parameters:”Parameter | Description |
---|---|
address | Target IP address |
interface | Interface name or id |
network | Network name or IP address |
show | Display specific information |
help | Display help message |
ip Command Samples:
Section titled “ip Command Samples:”Display Network Interfaces
Section titled “Display Network Interfaces”ip address show
Shows the configuration of all network interfaces on the system.
Assign an IP Address to an Interface
Section titled “Assign an IP Address to an Interface”ip address add 192.168.1.10/24 dev eth0
Assigns the IP address “192.168.1.10” with a subnet mask of 24 to the interface “eth0”.
Bring Down an Interface
Section titled “Bring Down an Interface”ip link set eth0 down
Brings down the network interface “eth0”.
Display the Routing Table
Section titled “Display the Routing Table”ip route show
Displays the current routing table of the system.
Add a Static Route
Section titled “Add a Static Route”ip route add 192.168.2.0/24 via 192.168.1.1
Adds a static route for the network “192.168.2.0/24” via the gateway “192.168.1.1”.
Flush ARP Cache
Section titled “Flush ARP Cache”ip neigh flush all
Flushes the ARP cache, removing all entries.
Manage IPv6 Addresses
Section titled “Manage IPv6 Addresses”ip -6 address show
Displays IPv6 addresses and related information for all interfaces.
ip FAQ:
Section titled “ip FAQ:”How do I use ip in Linux?
Section titled “How do I use ip in Linux?”To use the ip command in Linux, execute the following command:
ip --option <value>
How can I display information about network interfaces using ip?
Section titled “How can I display information about network interfaces using ip?”You can display information about network interfaces using the following ip command:
ip addr show
How do I add a new IP address to a network interface with ip in Linux?
Section titled “How do I add a new IP address to a network interface with ip in Linux?”To add a new IP address to a network interface using the ip command, run the following command:
ip addr add <ip_address>/<subnet_mask> dev <interface>
How can I list all the routes with ip in Linux?
Section titled “How can I list all the routes with ip in Linux?”To list all the routes using the ip command in Linux, use the following command:
ip route show
How do I delete an IP address from a network interface with ip?
Section titled “How do I delete an IP address from a network interface with ip?”To delete an IP address from a network interface using the ip command, you can use the following command:
ip addr del <ip_address>/<subnet_mask> dev <interface>
How can I flush all IP addresses of a network interface with ip in Linux?
Section titled “How can I flush all IP addresses of a network interface with ip in Linux?”To flush all IP addresses of a network interface using the ip command, you can run the following command:
ip addr flush dev <interface>
Applications of the ip command
Section titled “Applications of the ip command”- Assigning an IP address to a network interface
- Bringing up or taking down a network interface
- Displaying information about network interfaces
- Managing routing tables and rules
- Setting up virtual network interfaces
- Managing ARP cache
- Managing Multicast addresses
- Managing tunneling interfaces