IFCONFIG - Documentation
Display Network Interfaces
To display all active network interfaces and their configurations:
ifconfig
This command will show information such as the interface name (e.g., `eth0`, `wlan0`), the IP address, the MAC address, and other network interface parameters.
To display all interfaces, including those that are down, use:
ifconfig -a
Configure an IP Address
You can configure an IP address for a network interface using the following syntax:
ifconfig <interface> <IP_address> netmask <netmask>
For example, to assign the IP address `192.168.1.10` with a subnet mask `255.255.255.0` to interface `eth0`, use:
ifconfig eth0 192.168.1.10 netmask 255.255.255.0
To assign an IP address to a wireless interface, for example `wlan0`, use:
ifconfig wlan0 192.168.1.10 netmask 255.255.255.0
Bring Interface Up or Down
To activate (bring up) a network interface, use:
ifconfig <interface> up
For example:
ifconfig eth0 up
To deactivate (bring down) a network interface, use:
ifconfig <interface> down
For example:
ifconfig eth0 down
Set MAC Address
You can change the MAC (Media Access Control) address of a network interface using the `hw` flag:
ifconfig <interface> hw ether <new_mac_address>
For example, to set a new MAC address on interface `eth0`:
ifconfig eth0 hw ether 00:11:22:33:44:55
Note: Changing the MAC address might require the interface to be brought down and up again.
Enable or Disable Promiscuous Mode
Promiscuous mode allows a network interface to receive all packets on the network, even those that are not addressed to it. To enable promiscuous mode:
ifconfig <interface> promisc
To disable promiscuous mode:
ifconfig <interface> -promisc
Example:
ifconfig eth0 promisc
View Network Statistics
To view detailed statistics for a network interface, including the number of packets sent and received, errors, collisions, etc., use the following command:
ifconfig <interface>
For example:
ifconfig eth0
This will display statistics like:
- RX (received) bytes - TX (transmitted) bytes - Errors, dropped packets, etc.
Set MTU (Maximum Transmission Unit)
The MTU defines the maximum size of a packet that can be transmitted over a network interface. To set the MTU for a network interface:
ifconfig <interface> mtu <mtu_size>
For example, to set the MTU size of `eth0` to 1500 bytes:
ifconfig eth0 mtu 1500
Set Broadcast Address
To set the broadcast address for a network interface:
ifconfig <interface> broadcast <broadcast_address>
For example, to set the broadcast address of `eth0`:
ifconfig eth0 broadcast 192.168.1.255
View a Specific Interface's Information
To view information about a specific network interface, simply specify the interface name:
ifconfig <interface>
For example, to display the information for `eth0`:
ifconfig eth0
Useful Links
- [Linux ifconfig Manual](https://man7.org/linux/man-pages/man8/ifconfig.8.html)
- [ifconfig Command Reference](https://linux.die.net/man/8/ifconfig)
- [Networking in Linux](https://www.tldp.org/HOWTO/Net-HOWTO.html)
- [Wikipedia: Ifconfig](https://en.wikipedia.org/wiki/Ifconfig)
- [Linux Networking Documentation](https://www.kernel.org/doc/html/latest/networking/index.html)
