Hello Geeks, when we install Debian Linux on our system then during the installation it tries to get DHCP ip address from modem (or dhcp server) if available. But it is always to recommended to have a static IP address on your system. In this post, we will cover how to configure static IPv4 address in Debian 11 (Bullseye). In Debian Linux, there are two ways to set or configure static IP address.
Configure Static IP Address from GUI
Login to your Debian Desktop environment, From Settings –> Choose Network
Click on Wired Settings and then we will get the following window,
Note: To disable IPv6, go to IPv6 tab and choose ‘Disable’ option
Click on IPv4 Tab
Above window shows that Automatic DHCP is configured, so to configure Static IP choose Manual and then specify the IP details like IP address, netmask, gateway and dns server IP.
Note: To Specify the dns server IP first disable the automatic dns IP by toggling it.
Click on Apply to save the changes.
Now, disable and enable the interface by toggling it so that new IP address is assigned to the Interface.
Now again click on wired settings to verify whether the new static ip address is assigned or not.
Perfect, above confirms that new static IP address is configured successfully. Now let’s see the alternate way to configure IP address in Debian Linux.
Configure Static IP Address from Command Line
Open the terminal and identify the interface on which we will configure static IP address. Run below ip command,
$ ip add show
Now run nmcli command to get connection name,
$ nmcli connection
Once we get the connection name, run below nmcli command to assign static ipv4 address,
$ nmcli con mod ‘connection-name’ ipv4.address <IP-Address>
$ nmcli con mod 'eth0' ipv4.address 192.168.1.151/24
Set the gateway by running below
$ nmcli con mod 'eth0' ipv4.gateway 192.168.1.1
Change Configuration from DHCP to Manual , so that IP will be static and persistent, run
$ nmcli con mod 'eth0' ipv4.method manual
Set the DNS server IP by running below command,
$ nmcli con mod 'eth0' ipv4.dns '188.8.131.52'
Disable and enable the connection so that above changes come into the effect.
$ nmcli connection down eth0 $ nmcli connection up eth0
Now Run IP Command to check IP address,
$ ip add show eth0
Output of above commands would look like below:
Perfect, above output confirms that static IP address has been configured successfully on eth0 interface. That’s all from this post. Please do share your feedback and queries in below comments section.