Skip to content

ifconfig

Learn how to use the ifconfig command in Linux to view and configure network interfaces. Includes practical examples for IP addresses, MAC addresses, and interface status


Print info about network interfaces

ifconfig

Print info for a specifik network interface

ifconfig eno1

Print info for all network interfaces

ifconfig -a

Get all ip addresses

ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'

Dump ipv4/ipv6 addresses

ifconfig eno1 | grep inet | awk '{print $2}' | sed 's/addr://' | grep .

Dump ipv4/ipv6 addresses

ifconfig eno1 | grep inet | awk '{print $2}' | sed 's/addr://'

List all mac addresses colorized

ifconfig -a| grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'

List mac addresses

ifconfig -a | sed '/eth\|wl/!d;s/ Link.*HWaddr//' 

List mac address for a specifik network interface

ifconfig eno1 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'

List all available MACs address

ifconfig -a | sed '/eth\|wl/!d;s/ Link.*HWaddr//' 

Change mad address

eno1 = the name of the interface 00:01:02:03:04:05 = the new mac adresse the same thing for wireless card $ sudo iwconfig eno2 hw ether 00:01:02:03:04:05

sudo ip link set eno1 down
sudo ip link set eno1 address 00:01:02:03:04:05
sudo ip link set eno1 up
ip link show eno1                # Example 1: verify it worked
cat /sys/class/net/eno1/address  # Example 2: verify it worked

List your MACs address

ifconfig eno1 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'