ifconfig Command – Linux Network Management With Examples

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

ifconfig command is very old and popular tool used to manage Linux, Unix, Bsd systems network. Current this command alternative is ip tools commands but ifconfig popularity remains. Ifconfig command can create interface, network address, link or interface up , link or interface down etc. We will look in this tutorial popular features and usage examples of linux ifconfig command.

View All Network Configuration

Generally the first step after connecting a new server is looking its network configuration. Without providing any parameters to the ifconfig will print out all network configuration of the Linux system. This will list all active network interfaces configuration.

View All Network Configuration
View All Network Configuration

Display All Network Interfaces

Previously we have listed all network configuration of active network interfaces. If we want to get information about inactive or disabled network interfaces we should provides -a parameter to ifconfig command like below.

Display All Network Interfaces
Display All Network Interfaces

View Network Settings of Specific Interface

Servers generally have more than one interface and some times interface count of Linux system can exceed 10. In this situations looking specific network interface configuration can become hard job for us. Ifconfig can get specific interface name to list only its configuration.

View Network Settings of Specific Interface
View Network Settings of Specific Interface

Disable Network Interface

Network interfaces can be enable or disabled according to the situation. To enable or disable an interface user need root privileges. Disable a network interface will shutdown the interface and clear all configuration about it.

As we see in the flags line the interface have no keyword like UP which means it is down.

LEARN MORE  How To Convert Png To Jpeg And Vice-Versa

Enable Network Interface

Enabling an disable network interface is similar to the disabling it. We will just provide up keyword with the interface name to the ifconfig.

Enable Network Interface
Enable Network Interface

Assign IP Address To Network Interface

Assigning IP address to the network interface in Linux is easy with ifconfig. After assigning the IP address to the interface the address can be used for operations. Keep in mind that this will remove current IP address and set new address so if you connected over network the network will be hang.

Assign Netmask To Network Interface

Assigning netmask is similar to the IP address but we willprovide the netmask keyword to the ifconfig like below.

Assign Broadcast Address To Network Interface

Broadcast address is used to announce to all hosts in the same network. Broadcase addesses generally used the last IP address in the network segment. But if it is different from last IP address we can set broadcast IP address with ifconfig like below.

Assign IP, Broadcast and Netmask Address To Network Interface

Previous there examples we have looked different operations to set interface configuration. These configurations are generally done in a single shot command like below. If we want to set IP address, netmask and broadcast address in single ifconfig command we will use following example syntax.

As we see in the command we provide first interface name and then the IP address. After those we provide netmask keyword and netmask value and the last one the broadcast keyword and address is provided.

LEARN MORE  How To Add New Repository To Apt In Linux

Change MTU for Network Interface

MTU is used the term Maximum Tranmission Unit. MTU sets the size of IP packets those travels on networks. The default value for MTU is 1500 but this can provide some bottlenecks so the MTU can be changed to the 1000 to solve problems. Packets those IP and upper layer data bigger than 1000 byte will not transmitted. Here is how to set MTU with ifconfig.

Change MTU for Network Interface
Change MTU for Network Interface

As we see ens3 network configuration the mtu value is set to 1000

Enable Promiscuous Mode

Operating systems network stacks filter out packets those are designated different IP address than its own. This means that is a packet designated 192.168.122.5 IP address comes to 192.168.122.10 this packet is dropped by default. But there is a configuration to accept these packets. It is called promiscuous mode. When promiscuous mode is enable all packets are received by network protocol stack.

Enable Promiscuous Mode
Enable Promiscuous Mode

As we see ens3 configuration have a feature named PROMISCUOUS in the first line of configuration.

Disable Promiscuous Mode

Disabling promiscuous mode is very easy. Just provide minus before promisc option.

Disable Promiscuous Mode
Disable Promiscuous Mode

Add Second IP To Network Interface

Linux operating system have the ability to set multiple IP addresses into single interface. Only restriction about IP address is that alternative IP addresses must be in the same network. This operation is called as adding new alias to the network interface.

Add Second IP To Network Interface
Add Second IP To Network Interface

Remove Second IP From Network Interface

Removing alias or alternative IP addresses can be done like below.

LEARN MORE  How To Clear Linux History File Easily?

Remove Second IP From Network Interface
Remove Second IP From Network Interface

Change MAC Address of Network Interface

MAC addresses are assigned by the hardware manufacturer. Generally known as unchangeable but in the network stack MAC addresses can be changed. Use following command to change MAC address.

Change MAC Address of Network Interface
Change MAC Address of Network Interface
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/ifconfig-command-linux-network-management-examples/
PINTEREST
PINTEREST
INSTAGRAM

One Reply to “ifconfig Command – Linux Network Management With Examples”

Leave a Reply

Your email address will not be published.