Linux ip Command With Examples- Network Management – POFTUT

Linux ip Command With Examples- Network Management

Linux network stack provides a lot of network-related features like a commercial network router or switch. There are different tools and ways to manage these advanced features. In this tutorial, we will look ip toolset which is a new generation tool designed to manage Linux network configuration.

Show IP Address

An IP address is a number used in the network to access a host.

OR

Show IP Address

Show IP Address

As we see the same command can be expressed in different ways. I prefer short one like ip add which is the same ass ip address show

Set IP Address

Setting the IP Address will create new IP address of the interface and do not delete the existing IP address. To set IP address root privileges are required so we use sudo .

Set IP Address

Set IP Address

Remove IP Address

Removing IP address from an interface syntax is the same as the adding. Just the add keyword is changed with del keyword like below. This will remove the specified IP address from that interface.

Remove IP Address

Remove IP Address

Flush, Remove All IP Addresses

Removing IP addresses one by one is away but if we need to remove remove all IP addresses in a single command easily flush can be used like below.

Enable Network Interface

Interfaces can be enabled with the following command. This will bring interface into the downstate. In network terminology, this is called UP

LEARN MORE  How To Find IP Address On Windows?

Enable Network Interface

Enable Network Interface

Disable Network Interface

Disabling network interfaces are very similar to the enabling network interfaces. Just up keyword is changed with down keyword.

Disable Network Interface

Disable Network Interface

Change MTU

Maximum Transmission Unit is a configuration used to specify the size of a single package that can be transmitted over the network. By default, MTU is set to 1500. This values can be changed according to the network and applications special needs.

Change MTU

Change MTU

Show Routing Table

Linux provides powerful routing mechanism but this feature is generally used for only Linux host, not for the whole network. The routing table can be listed with the ip route command like below. To list routing table of Linux there is no need for root privilege

OR

Show Routing Table

Show Routing Table

Add Static Route

Adding route requires root privileges. Adding new root is similar to the adding new IP address as we see below.

Add Static Route

Add Static Route

Remove Static Route

Removing a static route is as easy as adding it. We will change add keyword with del keyword like below. Removing static route also requires root privileges too.

LEARN MORE  DHCP Reservation For Windows Server 2012, Windows Server 2008 and Benefits

Remove Static Route

Remove Static Route

Persistence Static Route

Adding a route with ip command will make them available for the current run. After boot, the added routes will be deleted because they are not persistence. We will add our routes to the network configuration of the distribution which is different from distribution. We will look at Ubuntu and Fedora-based distributions below.

Ubuntu, Debian, Kali, Mint:

Add following line to the /etc/network/interfaces file.

Persistence Static Route

Persistence Static Route

To enable these persistent static routes without restarting systems restart networking system with the following system.

Fedora, RedHat, CentOS:

Add following line to the /etc/sysconfig/network-scripts/route-eth0 where eth0 is the name of the link or interface

Persistence Static Route

Persistence Static Route

To enable these persistent static routes without restarting systems restart networking system with the following system.

List/Show Default Gateway

The default gateway is a route which is preferred to other routes if the destination is not found in the routing table. Listing routes will also list default gateway in the first line like below.

List Default Gateway

List Default Gateway

default via 192.168.122.1 dev ens3 is our default route

Add Default Gateway

New default gateways can be added to the Linux system. It is like adding new routes by providing default keyword. We do not specify the destination network or host because the default gateway is used for unknown destination networks.

LEARN MORE  What Is NAT (Network Address Translation) and How It Works?

Remove Default Gateway

Removing, deleting default gateway or route is very similar to the adding default gateway or route. Changing add keyword with del will remove same added default route like below.

List Arp Table

Address resolution protocol is used to identify IP – Mac address matches. Hosts store these matches for some time and then remove from their Arp table. Arp table populated with the known IP – Mac addresses records.

List Arp Table

List Arp Table

IPv6

By default, all ip commands are interpreted as IPv4. If we need to specify IPv6 -6 option can be used. -4 option also used for IPv4

IPv6

IPv6

Show Bridge Devices

Bridge devices generally used to share some devices with different applications or virtual systems. Bridges devices can be listed with the following command.

Show Bridge Devices

Show Bridge Devices

Show Vlan Devices

Virtual Local Area Network’s (VLAN) used to isolated networks in a single physical line. These devices can be listed with the following command.

1 Response

  1. 27/02/2018

    […] Linux Ip Command With Examples- Network Management […]

Leave a Reply

Your email address will not be published. Required fields are marked *