How to use IP commands to configures network interface in Linux

Introduction

The IP command is a Linux netting tool for the network administrators and system. IP stands for Internet Protocol. As the title implies, the tool is operated for configuring network interfaces. Older Linux allotments utilized the ifconfig command, which works likewise. Nevertheless, ifconfig has a narrow range of credentials than the IP command.

This article goes through all the IP command’s fundamental operations in Linux and explains the use of IP to centrifuge network interfaces.

ifconfig is the abbreviation of “interface configuration” utility for network/system administration in Linux/Unix functioning systems to configure, query, and control network interface parameters via system configuration scripts or a command-line interface.

The “ifconfig” command is operated to show the current network configuration statement, put up an IP address, broadcast address, or netmask to a network interface, construct an alias for the network interface, enable or disable network interfaces, and set up hardware address.

The IP command is a unique networking command-line value operated to allocate an IP address to a configure/update or network interface functional network variables on a Linux system. It is a portion of the iproute2 system. It suggests several network administration assignments such as getting up or down network interfaces, managing ARP cache, assigning and removing IP addresses and routes,  and more.

The IP command is identical to the old config command, but it is extensively more potent with more practical, and credentials added.

The ifconfig command has been deprecated and superseded by the IP command in all modern Linux allocations. Nevertheless, the ifconfig command is still working and unrestricted for most Linux distributions.

Use of  IP commands to configures network interfaces

IP command is a command with better characteristics than ifconfig. The command allows doing miscellaneous tasks linked to network administration. Today, the ifconfig command is the short used command.

Specifying and Removing an IP Address

$ Sudo ip addr Add IPaddress/24 Dev

In the above syntax, the IP address possesses a prefix. This is operated to display the subnet mask used.

(Substitute IP address with the identical IP address)

To confirm the changes, the show command can be

helpful too.$ IP addr show Wlan0

The exact steps can guide you to delete the IP address by substituting the add with del command.

Show Routing Table Entry System

The entries created in this table are defaulting and can be changed later. IP commands are primarily operated to consider the route packets teaching to the network, as cited in the routing table. In this model, there are several routes. These impact from having different devices connected through the various network interfaces. These contain internet, WIFI, and a point-to-point link.

$

IP Route Show

To show the routing packet of a defined IP address

$ ip Route get an IP address

(Substitute IP address with the identical IP address)

Modifying The revert Route

The default route can be modified employing the IP commands as observed.

$ Sudo IP route add revert via IP address

(Substitute IP address with the identical IP address)

Show Network Statistics

The different interface statistics can be considered by determining the option ls followed by the title of the network interface.

$ ip -S link

Option -S is operated to consider more details related to the respective interface. These are mainly performed at the time of troubleshooting misconceptions in network connectivity.

$ ip  -S link Ls eth0

ARP Entries

The known translation address to its MAC address can be accomplished with the support of the Address Resolution Protocol (ARP). The IP command and alternative neighbor or neigh are used to show the MAC address of the LAN-connected widgets.

$ ip neighbor

How to operate the Linux IP command

These are the syntax of the IP command.

$ ip [ OPTIONS ] ENTITY { COMMAND | help }$ ip Help

ENTITY is the object sort that you like to manipulate, which includes:

  1. Link (l): It shows and changes network interfaces.
  2. Address (a): It displays and changes IP addresses.
  3. Route (r): It shows and changes the routing table.
  4. Neigh (n): It shows and adjusts the ARP table.

You can operate the complete or short form to complete the command. For example, an IP address IP addr will show the exact output.

1. Show and Manage IP Addresses

The IP addr command permits you to display, delete IP addresses, and assign them in a Linux system. The IP addr entity uses the following syntax.

IP addr [ COMMAND ] ADDRESS dev IFTITLE

Operate the help command to locate more regarding address commands.

IP addr Help

Show an index of all network interfaces.

The IP addr displays a command index of all the network interfaces and appointed IP addresses.

For example:

IP addr Show

To show output for only IPv4 or IPv6, operate the following command.

To show IPv4 IP addressIP -4 addrTo show IPv6 IP addressIP -6 addr

Show details about distinct network interface

To show information about a distinct interface, use the following syntax.

IP addr show dev [Device Identification]

For example, to show information about ens33, type the following.

IP addr show dev ens33

Allocate an IP address to an interface

Use IP addr add command to allocate an IP address to an interface.

Syntax:

He [ ADDRESS ] is the address you want to allocate to the [Interface Title].

For example, to count address 192.168.239.110 with subnet mask 24 to system ens33:

IP addr add 192.168.239.110/24 dev ens33

No result is shown if the IP address is added to the system or an error is exhibited.

Add many IP addresses to an interface.

To add many IP addresses to an interface, you must use the exact command multiple times overhead.

For example, rank the following: add addresses 192.168.239.110 and 192.168.239.105 with subnet mask 24 to device ens33.

IP addr add 192.168.239.110/24 dev ens33IP addr add 192.168.239.105/24 dev ens33

Deleting an IP address from an interface

To remove an IP address from an interface, operate the following syntax.

IP addr del [ ADDRESS ] Dev [ Interface Title]

For example, organize the following: delete address 192.168.30.120 with subnet mask 24 from device ens33.

ip addr del 192.168.239.110/24 dev ens33

No outcome is shown if the IP address is deleted from the system or an error is displayed.

  1. Show and Manage Network Interfaces

The IP link command operates and shows the state of all network interfaces. You can specify IP/TCP accumulation network interface importance such as txqueuelen, MTU, and interface up/down. We can operate the IP link established command for this.

To show a list of link object commands, you can utilize the help command as follows.

$ ip link Help

Obtain Network Interface Information

The IP link shows command exhibit details for all network interfaces.

$ ip link Show

To show information regarding a specific device, utilize the following syntax.

$ ip link show dev [Device TITLE]

For example, you would use the following to show network details about ens33.

$ ip link show dev ens33

Selects interface standing as UP or DOWN

To arrange the interface up or down, operate the following syntax.

IP link set dev [ Device TITLE] [ up/down ]

For instance, to get ens33 online, use the subsequent command.

IP link set dev ens33 Up

No outcome is shown if the system is turned up or an error is displayed.

Also, to get ens33 down, utilize the following command.

IP link set dev ens33 Down.

No outcome is shown if the system is turned down or an error is displayed.

Alter txqueuelen of the system.

To modify the transfer queue of a system, use the following syntax.

IP link set txqueuelen [ Digit ] dev [ Interface Title]

For example, utilize the following command to set the transfer queue 5 of the ens33 system.

ip link set txqueuelen 5 dev ens33

No outcome is shown if the transfer queue is set or an error is displayed.

  1. How to Promote Network Interface

The “up” flag with interface title(eth1) allows a network interface. For example, the subsequent command will trigger the eth1 network interface.

# ip link set eth1 Up$ Sudo ip link set eth1 Up

  1. How to Vandalize Network Interface

The “Down” flag with interface Title (eth1) vandalizes a network interface. For example, the subsequent command will Deactivate the eth1 network interface.

# ip link set eth1 Down$ Sudo ip link set eth1 Down

Verdict

The ifconfig utility is a valuable tool for adding and managing network connections on Linux systems. It gives uncomplicated command-line options to assist you to configure networking, especially on headless servers. This guide demonstrates how to add and manage network connections with the ifconfig command in Linux. You now know Linux’s IP command and how to use the command to assist in network/system administration.

You May Also Like

About the Author: admin