Mastering ifconfig: How to View and Configure Network Interfaces on Linux
Learn how to use the Linux ifconfig command to display network interface details, configure IP addresses, modify MAC addresses, enable or disable interfaces, and set advanced options like netmask, MTU, and IPv6 addresses, with clear syntax explanations and practical examples.
ifconfig: Display or configure network parameters
Function description
The ifconfig command is used to display or configure network parameters of host network interfaces, such as setting IP addresses, modifying MAC addresses, and bringing interfaces up or down.
Configurations made with ifconfig are temporary; they disappear after a reboot. To make changes permanent, edit the network interface configuration files.
Command syntax
ifconfig [interface] [options] [IP address]Option meanings
-a : Show the status of all network interfaces
up : Bring the specified network device up
down : Bring the specified network device down
add <address> : Set an IPv6 address on the network device
del <address> : Delete an IPv6 address from the network device
IP address : Specify the IPv4 address for the network device
netmask <subnet mask> : Set the subnet mask for the network device
mtu <bytes> : Set the Maximum Transmission Unit for the network device
hw <type> <hardware address> : Set the hardware MAC address of the interface
Reference examples
Example 1: View network interfaces
// Show active network interfaces only
# ifconfig
// Show all network interfaces, regardless of state
# ifconfig -a
// Show information for a specific interface (e.g., ens33)
# ifconfig ens33Example 2: Bring an interface up or down
// Bring interface ens33 up
# ifconfig ens33 up
// Bring interface ens33 down
# ifconfig ens33 downExample 3: Configure IP, change MAC address
// Set IP address and activate the device
# ifconfig ens33 192.168.154.131 netmask 255.255.255.0 up
// Add an IPv6 address
# ifconfig ens33 add 33ffe:3240:800:1005::2/64
// Delete an IPv6 address
# ifconfig ens33 del 33ffe:3240:800:1005::2/64
// Change the hardware MAC address
# ifconfig ens33 hw ether 00:0c:29:8e:14:c3Example 4: Configure an alias interface
// Create alias eth33:1 with a /16 netmask IP
# ifconfig ens33:1 192.169.1.6 netmask 255.255.0.0
// Bring the alias interface down
# ifconfig ens33:1 downOther examples
// Enable ARP protocol on the interface
# ifconfig ens33 arp
// Disable ARP protocol on the interface
# ifconfig ens33 -arp
// Set the maximum packet size (MTU) to 1500 bytes
# ifconfig ens33 mtu 1500Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
