IFCONFIG / IP:  Linux Command

IFCONFIG / IP: Linux Command

ยท

4 min read

Introduction ๐Ÿ‘‹๐Ÿฝ

These linux command are used to manage, control and configure all the networking things like IP, Interfaces Configurations , Netmask, Broadcast Addresses, MTU (Maximum Transmission Units) etc.

  • ifconfig (old way)
  • ip (new way)

I am also telling about ifconfig here (In case wanna learn only about โ€œipโ€, you can skip this part, most people are now switching to โ€œipโ€)

ifconfig (Interface Configuration)

2794209.jpg

This helps to get all the basic details of the active interfaces we have in the network, like Ethernet, Localhost, WLAN etc.

ifconfig

  • MAC (Media access control) address

A Media Access Control address (MAC address) is a hardware identifier that uniquely identifies each device on a network. Primarily, the manufacturer assigns it.

  • IP (internet protocol) address

An IP address, or Internet Protocol address, is a series of numbers that identifies any device on a network. Computers use IP addresses to communicate with each other both over the internet as well as on other networks

  • MTU (Maximum Transmission Unit)

It is the maximum size of a packet in bytes that can be transferred on the network, if data is bigger in size than the MTU, then it get fragmented and then travel onto the network/internet.

Screenshot 2022-08-19 at 4.22.35 PM.png

Screenshot 2022-08-19 at 2.34.55 PM.png

  • Incase want to see all the interfaces irrespective of they are active or not

    ifconfig -a

  • Want to see only a specific interface.

    ifconfig "interface_name"

Screenshot 2022-08-19 at 2.41.26 PM.png

Features in ifconfig

  • Deactivate an interface

    ifconfig "interface_name" down

Screenshot 2022-08-19 at 2.48.35 PM.png

  • Activate an interface

    ifconfig "interface_name" up

Screenshot 2022-08-19 at 2.50.16 PM.png

  • Change the IP address of the interface

    ifconfig "interface_name" "ip_address"

Screenshot 2022-08-19 at 2.54.57 PM.png

  • Change the Netmask of the interface

    ifconfig "interface_name" netmask "netmask"

Netmask - Every network has its own id so that the routers can select a network in which they want to route a data packet, that Netword ID is called as Netmask.

Screenshot 2022-08-19 at 3.02.42 PM.png

  • Change the Broadcast address of the interface

    ifconfig "interface_name" broadcast "broadcast"

Broadcast - Incase we want to send the message/data to every one in the network, then we make the destination address as the broadcast address.

Screenshot 2022-08-19 at 3.32.15 PM.png

  • Same for MTU

    ifconfig "interface_name" mtu "mtu"

MTU (maximum transmission unit) - It means maximum size of a packet in bytes that can be transferred on the network, if data is bigger in size than the MTU, then it get fragmented and then travel onto the network/internet.

Screenshot 2022-08-19 at 3.41.16 PM.png

ip (internet protocol)

4782264.jpg

This command is used to show / manipulate routing, network devices, interfaces and tunnels.

Features in ip

  • To show all the interfaces.

ip address show

ip address

ip addr show

ip addr

ip a show

ip a

Screenshot 2022-08-19 at 3.58.24 PM.png

  • To show only version 4 or version 6 addresses

ip -4 addr

ip -6 addr

Screenshot 2022-08-19 at 4.01.58 PM.png

  • Want to see only a specific interface.

    ip addr show dev "interface_name"

show : Used to show the interfaces.

dev : Used to select a device from all the interfaces.

Screenshot 2022-08-19 at 4.53.47 PM.png

  • Add multiple IP addresses to an Interface

    sudo ip addr add "ip_address" dev "interface_name"

add : To add an IP to an Interface

dev : To select a device among all the interfaces in the HOST.

Addition of these IPs are temporary as the system boots up, all this will come back to the default once.

Screenshot 2022-08-19 at 5.05.04 PM.png

  • Delete IP addresse from an Interface

    sudo ip addr del "ip_address" dev "interface_name"

Screenshot 2022-08-19 at 5.08.25 PM.png

  • Link command

It is used to display link layer information, it will fetch characteristics of the link layer devices currently available.

ip link

ip -s link

ip link list

Screenshot 2022-08-19 at 5.18.50 PM.png

ip link set dev "interface_name" down

  • To activate

ip link set dev "interface_name" up

  • To deactivate

Conclusion ๐Ÿ™‡๐Ÿฝโ€โ™‚๏ธ

In this post, I discussed about Some networking command of linux which basically helps us to manage, control and configure the networking variables in the network like (ip, netmask, broadcasting address, mtu, etc).

NOTE : Try these commands on your terminal side by side and experiment with these commands.

type man "command name" for more details in your own terminal.

Screenshot 2022-08-19 at 6.40.04 PM.png

What's NEXT

IP ROUTE : Used to manage the static routing in the network.

Socials ๐Ÿค

Twitter

LinkedIn

Github

ย