
The ip command is a built-in network management utility that offers a wide range of features and tools to manage Linux network interfaces. It's an improved utility that combines the functionalities of legacy commands such as ifconfig, arp, and route to offer improved management, monitoring, and troubleshooting of your server network interfaces.
This article explains how to use the ip command to manage server network interfaces and ip objects such as links, addresses, rules, and neighbors. You will perform basic ip command functions such as interface configuration, routing, link, and network address management to efficiently manage your server interfaces.
Before you begin, you need to:
ip command functionalities.The ip command uses the following syntax to manage network information and interfaces on your server.
Within the above command:
ip command operation mode.link, address, route.add, del, show.The ip command displays network interface information at varying levels of detail depending on the object and options used.
Use the ip link show command to view information about all network interfaces available on the server.
Your output should be similar to the one below.
Based on the above output, the command displays the total number of available interfaces, the MTU value, state, and MAC address for each interface. Active interfaces use the UP state while inactive interfaces use the DOWN state. Interfaces with a DOWN state cannot send or receive network traffic on the server unless enabled.
Display network interfaces in an active and running state.
Output:
Use the -br option to display only important information about the network interfaces.
Output:
Use the addr option, or its a shorthand, with the ip command to view the full information including IP addresses on all network interfaces.
Your output should look like the one below.
To view specific information about a specific network interface, include the interface name after the ip command. For example, view information about the VPC interface, enp8s0.
Output:
Run the following command to view detailed statistics about a specific network interface. For example, enp8s0.
Your output should be similar to the one below.
IP addresses can be assigned to network interfaces using the Dynamic Host Configuration Protocol (DHCP) or static addressing to enable network connections on the interface. DHCP is the default address assignment protocol on most servers, but static IP addressing may be required when working with multiple addresses or new interfaces on your server. Follow the steps below to add or remove IP addresses on your server network interfaces.
Run the following command to add a new IP address on your network interface. Replace enp8s0 with your desired interface name.
The above command adds a new private network address 192.168.1.10 to the enp8s0 interface. Depending on your addressing scheme, the interface can run with multiple IP addresses that offer different functions or services on your server.
View the interface information to verify that the new IP address is available.
Output:
When using multiple IP addresses, you may need to configure routing to enable specific network connections to use the interface IP address.
Use the del option to remove IP addresses on network interfaces. For example, remove the 192.168.1.10/24 address on the enp8s0 interface.
View the interface address information to verify that the address is removed.
Output:
Static routing directs traffic to remote networks through a specific network interface or IP address as the next hop to reach the network. Network requests to unmatched destinations are directed through the default route via the main server interface, while requests to unknown routes may fail due to missing route information. Follow the steps below to configure static routes using the ip command on your server.
View the default IP routing table.
Your output should be similar to the one below.
Based on the above output, direct network addresses use the dev option while non-linked addresses use the via option to direct network traffic using the specified address as the next hop. The default route handles all unknown routes on the server unless specified in the routing table.
Add a new static route to a remote network such as 10.0.0.0/16 accessible through a server on the VPC network at 10.50.112.4 as the next hop.
View the routing table again to verify that the new route is available.
Output:
Disabling a network interface stops it from sending or receiving traffic without removing its configuration, which is useful for maintenance or troubleshooting.
Use the ip link set command to modify the status of a network interface with a specific option. For example, run the following command to disable the enp8s0 interface.
View the network interface status and verify that the state is DOWN.
Output:
Enable the network interface.
View the interface information to verify the new status.
Output:
MTU is the maximum size of a packet in bytes that can be transmitted over a network interface without fragmentation. The default MTU value on most network interfaces is 1500. Depending on your needs, modify the value to allow the transfer of large or small data packets on private networks such as a VPC network, as described in the following steps.
View your target interface MTU value. For example, the VPC interface enp8s0.
Verify the MTU value in your output similar to the one below.
Set a new MTU value on the interface. For example, 3000 to transfer large data packets and improve efficiency with other servers in the VPC network.
View the interface information again and verify the new MTU value.
Output:
You have explored the ip command on your Linux server and performed basic network interface management tasks. The ip command is important when troubleshooting, setting up IP addresses, and optimizing your server network connections. For more information and configuration options, run man ip to view the ip command manual.
0 Comments
Be the first to comment and share your perspective with the community.