How do I configure a network card to automatically obtain an IP address in Linux?
In a Linux system, you can configure network management tools (such as NetworkManager or ifconfig) to set the network card to automatically obtain an IP address. Here are two common methods:
Option 1: Utilize NetworkManager
- Open the terminal.
- Please open the NetworkManager.conf file using the nano text editor in sudo mode in the /etc/NetworkManager directory.
- [ifupdown]
control is enabled - Save and close the file.
- Restart the NetworkManager service using sudo systemctl.
Option 2: Utilizing the ifconfig command.
- Open the terminal.
- Show all network interfaces.
- Find the network interface that needs to be set up for automatically obtaining an IP address (usually starting with “eth” or “wlan”), and remember the name of that interface.
- Run the command “sudo dhclient
“
Both methods will allow the network card to automatically obtain an IP address. If you are using a desktop environment, you will typically use NetworkManager; if you are using a headless server, you can use the ifconfig command.