Linux Ip Command With Examples- Network Management

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-ip-command-examples-network-management/
PINTEREST
PINTEREST
INSTAGRAM

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 tool set which is new generation tool designed to manage Linux network configuration.

Show IP Address

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

OR

Show IP Address
Show IP Address

As we see 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 IP Address will create new IP address of the interface and do not delete 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 with the adding. Just the add keyword is changed with del keyword like below. This will remove specified IP address from that interface.

Remove IP Address
Remove IP Address

Flush, Remove All IP Addresses

Removing IP addresses one by one is a way but if we need 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 down state. In network terminology this is called UP

LEARN MORE  How To Install Perl Modules With CPAN?

Enable Network Interface
Enable Network Interface

Disable Network Interface

Disabling network interfaces is 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 single package that can be transmitted over 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. 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 easy as adding it. We will change add keyword with del keyword like below. Removing static route also requires root privileges too.

Remove Static Route
Remove Static Route

Persistence Static Route

Adding route with ip command will make the 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 from distribution. We will look Ubuntu and Fedora based distributions below.

LEARN MORE  Python Command Line Arguments

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

Default gateway is a route which is preferred to other routes if the destination is not found in 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 destination network or host because default gateway is used for unknown destination networks.

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 know IP – Mac address records.

LEARN MORE  How To Add or Change Default Route or Default Gateway in Ubuntu, Lnux?

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 virtaul 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.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-ip-command-examples-network-management/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.