Skip to content

ifconfig command in MacOS

The ifconfig command in MacOS is used to configure network interfaces, display current network configuration, set up new network configurations, or troubleshoot network connectivity issues. With ifconfig, users can view information about all network interfaces, assign IP addresses, enable or disable network interfaces, and adjust network settings as needed. This powerful command is essential for managing network connections on MacOS devices.

ifconfig Syntax:

Terminal window
ifconfig [interface] [options]

MacOS ifconfig Options:

OptionDescription
-aDisplay all interfaces
-vDisplay verbose output
-uDisplay interfaces configured up
-lDisplay interfaces configured down
-cReset packet counters
-tAdd a tunnel interface

ifconfig Parameters:

ParameterDescription
interfaceSpecifies the interface name (e.g., en0, en1) to show or configure
optionsOptional options to display or configure settings for the specified interface

How to use ifconfig command:

Show Interface Configuration

Terminal window
ifconfig

Displays the configuration of all network interfaces.

Show Detailed Interface Information

Terminal window
ifconfig en0

Displays detailed information about a specific network interface (in this case, “en0”).

Release DHCP Lease

Terminal window
sudo ifconfig en0 down

Releases the DHCP lease for the network interface “en0”.

Renew DHCP Lease

Terminal window
sudo ifconfig en0 up

Renews the DHCP lease for the network interface “en0”.

Set IP Address

Terminal window
sudo ifconfig en0 inet 192.168.1.10 netmask 255.255.255.0

Sets the IP address and netmask for the network interface “en0”.

Enable Promiscuous Mode

Terminal window
sudo ifconfig en0 promisc

Enables promiscuous mode on the network interface “en0”.

Disable Interface

Terminal window
sudo ifconfig en0 down

Disables the network interface “en0”.

Enable Interface

Terminal window
sudo ifconfig en0 up

Enables the network interface “en0”.

How do I use ifconfig in MacOS?

To use the ifconfig command in MacOS, execute the following command:

Terminal window
ifconfig

How do I display all network interfaces using ifconfig in MacOS?

To display all network interfaces using the ifconfig command in MacOS, run:

Terminal window
ifconfig -a

How do I enable a network interface using ifconfig in MacOS?

To enable a network interface using the ifconfig command in MacOS, use the following syntax:

Terminal window
sudo ifconfig en0 up

How do I disable a network interface using ifconfig in MacOS?

To disable a network interface using ifconfig in MacOS, you can use the following command:

Terminal window
sudo ifconfig en0 down

How do I assign an IP address to a network interface using ifconfig in MacOS?

To assign an IP address to a network interface using ifconfig in MacOS, you can use a command similar to this:

Terminal window
sudo ifconfig en0 inet 192.168.1.100 netmask 255.255.255.0

How do I change the MAC address of a network interface using ifconfig in MacOS?

To change the MAC address of a network interface using ifconfig in MacOS, you can run a command like this:

Terminal window
sudo ifconfig en0 ether 00:11:22:33:44:55

How do I display only IPv4 addresses using ifconfig in MacOS?

To display only IPv4 addresses using the ifconfig command in MacOS, you can use the following command:

Terminal window
ifconfig | grep 'inet '

How do I renew the DHCP lease using ifconfig in MacOS?

To renew the DHCP lease using ifconfig in MacOS, you can run the following command:

Terminal window
sudo ifconfig en0 dhcp

How do I display detailed information about a specific network interface using ifconfig in MacOS?

To display detailed information about a specific network interface using ifconfig in MacOS, use the following command format:

Terminal window
ifconfig en0

Applications of the ifconfig command

  • View network interface configuration
  • Enable or disable network interfaces
  • Assign an IP address to a network interface
  • Configure the subnet mask for a network interface
  • View the MAC (Media Access Control) address of a network interface
  • Check network connection status
  • View network statistics and traffic on interfaces