linux/ifconfig

Configure Network Interfaces

Display or configure network interface parameters.

network
configuration
interface
linux

Command

ifconfig

Explanation

`ifconfig` (interface configuration) is part of the net-tools package and allows users to configure network interfaces. It can bring interfaces up or down, assign IP addresses, and view current network settings. Modern systems often use `ip` commands instead of `ifconfig` for advanced functionality.

Common Use Cases

  • Check network interfaces and IP addresses
  • Assign temporary IP configurations
  • Enable or disable interfaces manually

Best Practices

  • Use `ip a` as a modern alternative for listing interfaces
  • Avoid persistent configurations with `ifconfig`; use network manager instead

Common Mistakes to Avoid

  • Forgetting `sudo` when modifying interfaces
  • Using `ifconfig` on modern systems without installing net-tools

Troubleshooting

Problem: Command not found

Solution: Install net-tools using `sudo apt install net-tools`.

Problem: Interface not showing

Solution: Use `sudo ifconfig -a` to display all interfaces, including inactive ones.

Examples

List all network interfaces and their details

ifconfig

Enable a network interface

ifconfig eth0 up

Assign IP address to interface

ifconfig eth0 192.168.1.10 netmask 255.255.255.0