• TechRepublic

Account Information

set static ip address debian command line

How to set a static IP address on Debian server

Share with Your Friends

Your email has been sent

Image of Jack Wallen

Jack Wallen walks you through the process of giving a standard user sudo privileges so they can set a static IP address on Debian server.

Debian is one of the most reliable operating systems on the planet. Its slower release cycle means each iteration gets plenty of attention before each release. And Debian isn’t just for desktops. In fact, Debian has been deployed as a server for years.

The one thing many new admins might find with deploying Debian as a server is that setting an IP address isn’t exactly as intuitive as other distributions. RHEL-based Linux distributions have the nmtui ncurses tools for configuring network connections, and Ubuntu-based distributions have netplan. With Debian, setting a static IP address is a bit more old-school, so I’m going to show you how it’s done.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

What you need to setup an IP address in a Debian server

To set the IP address on Debian server, you’ll need a running instance of the OS and either a user with sudo privileges or access to the root user account. I’ll show you first how to give a standard user sudo privileges.

How to give a standard user sudo privileges in a Debian server

Let’s create a new user first. I’ll demonstrate by creating the user olivia (you can name the user whatever you like). To do that, log into Debian server as the root user and issue the command:

adduser olivia

Once you’ve added the new user, add that user to the sudo group with:

sudo usermod -aG sudo olivia

Exit from the root user and log in with the new user account.

How to set a static IP address in a Debian server

The first thing you must do is locate the name of your network device. For that, issue the command:

ip -c link show

You should at least see two devices, lo (for loopback) and another named device (such as enp0s3).

Next, let’s back up the current network configuration file with the command:

sudo cp /etc/network/interfaces ~/

Open the configuration file for editing with the command:

sudo nano /etc/network/interfaces

If you find nano isn’t installed, add it with the command:

sudo apt-get install nano -y

With the interfaces file open for editing, you should see a DHCP configuration that looks like this:

# The primary network interface

allow-hotplug enp0s3

iface enp0s3 inet dhcp

Comment that block out so it looks like this:

# allow-hotplug enp0s3

# iface enp0s3 inet dhcp

Now, we can add the necessary configuration for a static IP address. Let’s configure enp0s3 to use the address 192.168.1.97, with a gateway of 192.168.1.1, and a DNS nameserver of 1.1.1.1. That configuration will look like this:

auto enp0s3

iface enp0s3  inet static

address 192.168.1.97

netmask 255.255.255.0

gateway 192.168.1.1

dns-domain example.com

dns-nameservers 1.1.1.1

Make sure to edit the above configuration to match your network scheme. Save and close the file.

Finally, restart the networking service with the command:

sudo systemctl restart networking

Make sure the networking configuration is correct, by issuing the command:

You should see the static IP address you configured. You’re good to go.

And that’s all there is to configure a static IP address in Debian server. Of course, if you installed your instance of Debian server with a desktop environment, you could simply use the GUI tool for this process. But for those who prefer to keep their servers sans GUI, this is the way to go.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

  • How to become a developer: A cheat sheet (TechRepublic)
  • How-to guide for Linux administrators (free PDF) (TechRepublic)
  • Linux 101: What tech pros need to know (TechRepublic Premium)
  • Linux, Android, and more open source tech coverage (TechRepublic on Flipboard)
  • See all of Jack's content
  • Open source

Editor's Picks

set static ip address debian command line

TechRepublic Premium Editorial Calendar: Policies, Checklists, Hiring Kits and Glossaries for Download

TechRepublic Premium content helps you solve your toughest IT issues and jump-start your career or next project.

set static ip address debian command line

7 Best AI Art Generators of 2023

This is a comprehensive list of the best AI art generators. Explore the advanced technology that transforms imagination into stunning artworks.

Close up of payroll summary detail with figures and euro.

The Best Cheap Payroll Services for 2023

Find the perfect payroll service for your business without breaking the bank. Discover the top cheap payroll services, features, pricing and pros and cons.

NordVPN logo.

NordVPN Review (2023): Pricing, Security & Performance

Is NordVPN worth it? How much does it cost and is it safe to use? Read our NordVPN review to learn about pricing, features, security, and more.

Task management software to organize project tasks, assign staff to finish work on schedule, project plan or efficiency work concept, business people team manage tasks assignment on computer laptop.

10 Best Free Project Management Software & Tools for 2023

Free project management software provides flexibility for managing projects without paying a cent. Check out our list of the top free project management tools.

Red cloud symbols with money and other symbols surrounding it.

Cloud Strategies Are Facing a New Era of Strain in Australia, New Zealand

Australian and New Zealand enterprises in the public cloud are facing pressure to optimize cloud strategies due to a growth in usage and expected future demand, including for artificial intelligence use cases.

Quality Assurance Checklist For Outsourced Projects

Quality assurance refers to the processes being used to manage the project and to build the deliverables. This is in contrast to quality control, which refers to the activities used to create the deliverables. Because you are not responsible for the creation of the deliverables (quality control), you need to be comfortable that the outsourcer ...

Cloud Computing Policy

The list of advantages to cloud computing include lowered operational costs, greater technological flexibility and the ability to rapidly implement new systems or services. Gains in business continuity are an especially noteworthy attraction to cloud services, which operate via remote systems that remain running in the event of a local disaster, such as a hurricane ...

Quick Glossary: Business Intelligence and Analytics

Business intelligence and data analytics give tech decision makers a clearer idea of how well their companies are running and whether they’re meeting goals. Because BI incorporates data from across the enterprise — revenue operations, sales, supply chain and logistics — its insight is beneficial in areas such as customer profiling, customer support and market ...

  • TechRepublic on Twitter
  • TechRepublic on Facebook
  • TechRepublic on LinkedIn
  • TechRepublic on Flipboard
  • Privacy Policy
  • Terms of Use
  • Property of TechnologyAdvice

Create a TechRepublic Account

Get the web's best business technology news, tutorials, reviews, trends, and analysis—in your inbox. Let's start with the basics.

* - indicates required fields

Sign in to TechRepublic

Lost your password? Request a new password

Reset Password

Please enter your email adress. You will receive an email message with instructions on how to reset your password.

Check your email for a password reset link. If you didn't receive an email don't forgot to check your spam folder, otherwise contact support .

Welcome. Tell us a little bit about you.

This will help us provide you with customized content.

Want to receive more TechRepublic news?

You're all set.

Thanks for signing up! Keep an eye out for a confirmation email from our team. To ensure any newsletters you subscribed to hit your inbox, make sure to add [email protected] to your contacts list.

Debian

  • RecentChanges
  • HelpContents

NetworkConfiguration

  • Attachments

3 ways to configure the network

Starting and stopping interfaces, reinitialize new network setup, network interface names, using dhcp to automatically configure the interface, configuring the interface manually, setting the speed and duplex, bringing up an interface without an ip address, the resolv.conf configuration file, the resolvconf program, dns configuration for networkmanager, using systemd-resolved for dns resolution, dhcp client configuration, bridging without switching, manual config, network init script config, bridges and vlans, caveats when using bridging and vlan, network config, bonding with active backup, /etc/network/interfaces, how to set the mtu (max transfer unit / packet size) with vlans over a bonded interface, legacy method, iproute2 method.

  • The interfaces configuration file at /etc/network/interfaces (this page): for basic or simple configurations (e.g. workstation)

Setting up an Ethernet Interface

Upgrading and network interface names.

  • Identify the interface in question (it will often be eth0). Adjust the remainder of these instructions accordingly.
  • Reboot the machine to make sure it comes up correctly, and be prepared to intervene manually (e.g. Ctrl-Alt-Del and then boot into single-user mode from GRUB or LILO) if things don't work.

Defining the (DNS) Nameservers

  • DHCP clients
  • Choose a connection (from the Wired or Wireless tab) and click Edit.
  • Click on the IPv4 Settings tab
  • Choose 'Automatic (DHCP) addresses only' instead of just 'Automatic (DHCP)'.
  • Enter the DNS servers in the “DNS servers” field, separated by spaces (e.g. 208.67.222.222 for OpenDNS).
  • Click “Apply.”

Enabling systemd-resolved

Checking the status and flushing the cache in systemd-resolved, managing systemd-resolved settings, setting additional dns servers, setting additional search domains, howto use vlan (dot1q, 802.1q, trunk) (etch, lenny), howto create fault tolerant bonding with vlan (etch - stretch).

debian_bonding.png

Multiple IP addresses on one Interface

NetworkConfiguration ( last modified 2023-07-18 11:37:31 )

  • Debian privacy policy , Wiki team , bugs and config .
  • Powered by MoinMoin and Python , with hosting provided by Metropolitan Area Network Darmstadt .

Tech Addressed

Linux Basics: Configuring A Static IP In Debian

This tutorial details how to configure networking for a static IP in Debian. Most Debian systems configure network settings one way, however, there is one exception to the rule that I’m familiar with that I detail how to configure well. This tutorial was written for headless Debian 11 “Bullseye” installs but should work with other versions of Debian as well. When Debian 12 “Bookworm” is released, I will update this tutorial as necessary.

Before We Begin

Above, I mentioned that this tutorial is meant for headless systems. If you don’t know what headless means in this context – it’s a reference to a system/server without a graphical interface or even without a monitor attached at all. All changes to a headless system are generally done through a remote connection using a command line terminal.

The reason this tutorial is specific to headless systems is that a system with a graphical interface setup is likely using a graphical program called Network Manager to handle configuring networks for the system.

IP Address / Subnet Basics

If you’re using this tutorial, there’s a chance you might not have a strong knowledge of IP addresses and subnet masks. If you need to brush up on some basic info on IP addresses and subnets, I’ve written an additional tutorial that should give you enough understanding to complete this tutorial.

Check Your Existing IP

First things first – before we modify any settings, let’s have a look at the existing IP address on your system. By default when you install Debian your networking is configured via DHCP. Run this command in the terminal to check your existing IP address:

The output should look similar to this but specific to your system:

Screenshot - Checking IP addresses in Debian

Notice for the device eth0@if2 (this is the network device for my my LXD container based demo environment) that the address is listed as dynamic meaning that the IP has been assigned via DHCP.

If your results don’t say dynamic, your system is already configured with a static IP address and no further changes are necessary unless you need to modify the server to use a different IP address.

Once you’ve determined that your system does indeed have a dynamic IP address, you can proceed with modifying your configuration for a static IP.

Modifying The Networking Interfaces File

Most Debian systems use the file /etc/network/interfaces for configuring your network settings.

To edit this file, we’ll use the nano editor as it’s fairly easy to use:

Your default interfaces file should look similar to this:

Default Debian Networking Interfaces File

Start by modifying the line that says iface eth0 inet dhcp by changing dhcp to static . Next we need to provide a networking configuration. You’ll need to determine what IP address, netmask – netmask is another term for subnet mask, gateway, and dns nameserver settings are necessary for your own network.

If it’s helpful, these are the settings I’ve used in creating this tutorial:

I’ll take a moment to mention – you can use whatever DNS nameservers you prefer on your systems. On server systems I prefer to use Cloudflare’s 1.1.1.1 public DNS for their lightning fast speed. On desktop systems, I prefer to use Quad9’s DNS servers as I prefer the additional privacy / security their system offers.

Once you’ve finished making changes, the resulting configuration should look similar to this:

Debian Networking Interfaces File Modified For A Static IP Address

To exit saving the changes you’ve made, on your keyboard press CTRL + X and when prompted to save press Y for yes.

Once the file has been saved, you’ll need to restart networking for these changes to take effect. Do this using this command:

and then check the IP address to verify that your new settings have applied:

The output should look similar to this:

Checking For Static IP Address In Debian

If we check the eth0@if2 interface again, notice that the address is now the static IP I’ve specified and it is no longer showing as being dynamic.

Setting A Static IP In Debian LXD Containers

For whatever reason, Debian configures their networking differently than normal in LXD containers . I make use of LXD containers in my homelab all the time – running various services as well as for setting up test environments and demos.

In LXD containers, Debian makes use of the networkd feature in systemd for networking. To modify the settings, you’ll need to find the config file for the network device you wish to configure inside the /etc/systemd/network/ directory. If you didn’t change the ID of your network interface for your container config, it should be /etc/systemd/network/eth0.network .

The default DHCP configuration should look like this:

Default Networkd Configuration In Debian LXD Containers

To modify this configuration, we’re going to delete the line that says DHCP=true and replace it with settings like these, however, be sure to use settings appropriate for your own network:

I’ll take a moment to mention – like I did in the previous section – you can use whatever DNS nameservers you prefer on your systems. On server systems I prefer to use Cloudflare’s 1.1.1.1 public DNS for their lightning fast speed. On desktop systems, I prefer to use Quad9’s DNS servers as I prefer the additional privacy / security their system offers.

Once you’ve finished your changes, the resulting configuration should look similar to this:

Modified Networkd Configuration In Debian LXD Containers

Unlike your typical Debian system where you can easily restart the networking service to apply the changes, when you’re using Debian in a LXD container the simplest solution to applying the network changes is to restart your container.

Once your container is restarted, you can check that the changes have applied from your host system by just bringing up a list of the system’s containers using this command:

The output of this command should look similar to my system – though if you’re reading this tutorial you probably won’t have as many containers:

Example LXD Container List

Additionally, you can check for the static IP in Debian as normal from the system terminal with this command:

Setting a static IP in Debian isn’t difficult once you know how to do it. If you’ve used this tutorial to prepare a system for a server application – perhaps like Pi-hole , Gitea, or Minio – you’re now ready to continue setting up your new server app.

If you found this tutorial helpful and would like to support our efforts to create additional resources like this, please consider making a donation . Your support is greatly appreciated!

If you can’t make a donation, please consider sharing this tutorial with others who may be interested. If you have questions about anything regarding this tutorial, please be sure to leave them in the comments below. Thanks for reading, and I hope you visit again soon!

About The Author

set static ip address debian command line

Robert Partridge

Related content.

Installing Pi-hole on TrueNAS Scale Featured Image

Installing Pi-hole On TrueNAS Scale

ubuntu featured

Linux Basics: Configuring A Static IP In Ubuntu

Basic Pihole Config Featured Image

Basic Pi-hole Configuration

Screenshot from the official Vaultwarden wiki

Easily Self Host Vaultwarden Using Docker Compose

Leave a comment cancel reply.

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

I accept the Privacy Policy

Start typing and press enter to search

How to Assign Static IP Address on Debian 12

In this blog post, we will show you how to assign static ip address on Debian 12.

In the world of Linux, Debian remains one of the most popular distributions, known for its stability and versatility. One essential aspect of managing a Linux system is configuring network settings. Whether you’re setting up a server or just want a consistent IP address for your desktop, assigning a static IP address on Debian 12 can be a crucial task.

Table of Contents

Prerequisites

  • Pre-Installed Debian 12
  • Sudo User with admin rights

There are different methods through we can assign static ip address on Debian 12.

Method1: Assign Static IP Address on Debian 12 Using GUI

Login to your Debian Desktop environment, From Activity –> Search Settings –> Choose Network

Network-Settings-GUI-Debian12

Click on Wired Settings and then we will get the following window,

Default-Wired-Settings-GUI-Debian12

Note: To disable IPv6, go to IPv6 tab and choose ‘ Disable ’ option

Click on IPv4 Tab

IPv4-Automatic-Wired-Settings-GUI-Debian12

Above window shows that Automatic DHCP is enabled, so to Assign Static IP choose ‘ Manual’ and then specify the IP details like IP address, netmask, gateway and dns server IP.

Important Note: To Specify the dns server IP first disable the automatic dns IP by toggling it.

Assign-Static-IP-Address-Debian12-GUI

Click on Apply to save the changes.

Now, disable and enable the interface by toggling it so that new IP address is mapped to the Interface.

Now again click on wired settings to verify whether the new static ip address is assigned or not.

Check-IPv4-Details-Network-GUI-Debian12

Perfect, above confirms that new static IP address is assigned successfully.

Method2: Assign Static IP Address on Debian 12 From Command Line

Open the terminal, check your current network configuration. You can do this by running the following ip command ,

IP-Command-Output-Debian12-Command-Line

This will display a list of network interfaces on your system. Note down the name of the interface you want to assign a static IP address to (typically, it’s ‘ enp0s3 ‘ for Ethernet).

Next, run nmcli command to get connection name,

nmcli-connection-command-debian12

Once we get the connection name, run below nmcli command to assign static ipv4 address,

$ nmcli con mod  ‘connection-name’ ipv4.address  <IP-Address>

Set the gateway by running below

Change Configuration from DHCP to Manual , so that IP will be static and persistent, run

Set the DNS server IP by running below command,

Disable and enable the connection so that above changes come into the effect.

Assign-Static-IP-Address-Debian12-Nmcli-Command

Now run IP Command to check IP address,

Output of above commands would look like below:

ip-add-show-enp0s3-debian12

Perfect, above output confirms that static IP address has been assigned successfully on enp0s3 interface.

Assign Static IP Address on Minimal Installed Debian 12

Whenever we install minimal Debian 12 then we will have only the CLI console and don’t have any nmcli utility. So, to assin static ip address we must edit the file ‘ /etc/network/interfaces ’.

Minimal-Debian12-Interface-File

Edit the file and set the static IP address as shown below,

Replace the line ‘ allow-htplug enp0s3 ’ with ‘ auto enp0s3 ‘ and change dhcp parameter to static .  Below is my sample file, change interface name and ip details as per your environment.

save & close the file.

Minimal-Debian12-Interface-File

To make above changes into the effect the restart the network service

Now, run ip command to verify the ip address,

IP-Add-Show-Minimal-Debian12

That’s all from this post. Please do share your feedback and queries in below comments section.

Assigning a static IP address on Debian 12 is a straightforward process that can greatly benefit your network stability and ease of access. By following the steps outlined in this guide, you can ensure that your Debian 12 system always has a consistent IP address, making it easier to manage and access your resources. Whether you’re configuring a server or just prefer having a stable address for your desktop, Debian 12 provides a user-friendly environment for all your networking needs.

Also Read : How to Install Kubernetes Cluster on Debian 12 | 11

2 thoughts on “How to Assign Static IP Address on Debian 12”

Nice Guide. Appreciate it.

In case someone has used “sudo raspi-config” > Advanced Options > Network Interface Names > Would you like to enable predictable network interface names ?

pi@pi-san-rasp:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.addresses 192.168.1.10/24 pi@pi-san-rasp:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.gateway 192.168.1.1 pi@pi-san-rasp:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.method manual pi@pi-san-rasp:~ $ sudo nmcli connection modify Wired\ connection\ 1 ipv4.dns ‘8.8.8.8’ pi@pi-san-rasp:~ $ sudo reboot

Excellent, thanks.

Leave a Comment Cancel reply

FOSS Linux

@2023 - All Right Reserved.

How to set up a static IP address on Debian 11

configure static ip address on linux mint

W hen installing any operating system, it is always set to receive network configuration from the DHCP (Dynamic Host Configuration Protocol) server. That includes IP address, routing, subnet, Gateway address, DNS information, and other network configurations. While that is always ok and enough to give you access to the internet, there are situations where a static IP address would be much more preferred. The main challenge with using the DHCP to assign IP addresses is that the IP is dynamic and might change.

To better understand the difference between Static and dynamic examples, let’s use a simple example. You have WiFi at your house, but you decide to go to a coffee shop with your laptop and use the internet there. When you come back to your home, there is a high probability that the DHCP will assign you a different IP address.

Why use a static IP

Some of the advantages of using a static IP include;

  • It’s much easier to set up and manage DNS
  • Reliable hosting services: Let’s say you are hosting a web server, game server, email server, or file server. Using a static IP will make it easier for clients to find you on a local network.
  • Reliable Remote access: A static IP address would be more reliable if you connect to your system via SSH or a VPN.
  • Reliable communication: Static Ip addressing ake it easier to configure VoIP (Voice Over Internet Protocol) and any other Video or Voice communication over IP.
  • Reliable geo-location services: With static IPs, you will get much more accurate geo-location services than a dynamic IP. For example, if you want to know the weather status in your location, you are sure you won’t get weather information from another city.

Setting up a static IP on Debian 11

This post will guide you on setting up a static IP on Debian 11. There are two main methods that we can utilize.

  • Set up static IP via the Terminal
  • Set up static IP from the GUI

We will look at both methods. Let’s get started.

(Method 1) Set up static IP via the terminal

Before configuring our static IP address, we need to know the network interfaces we are connected to. There are several commands that we can use to achieve that. One of the most popular commands to list network interfaces on Linux is the ifconfig command. Unfortunately, this command is now deprecated and doesn’t come pre-installed on most systems.

The other command to list network interfaces is the IP command. Execute the command below on your Terminal.

list network interfaces

List network interfaces

From the image above, you can see we are connected to the network interface ens33 and the currently assigned IP address is 192.168.1.52 .

With that information, we can now set our static IP address. Execute the command below to open the /etc/network/interfaces configuration file with nano editor.

If you have not done any configurations before, the file will look as shown below.

configure interfaces

configure interfaces

To set a static IP, add lines below at the end of the file.

Now let’s go through the line above:

  • auto ens33 : Here, we specify that we want to use the ens33 network interface.
  • iface ens33 inet static : This line specifies that we want to set a static IP address for our network interface.
  • address : Here, we set the static IP address that we want to assign to our network interface.
  • netmask : Here, enter the subnet mask
  • gateway : Here, type the gateway address. If you are unsure, use the IP route command to list the gateway address.
  • dns-nameservers : Enter your name servers here. For this post, we will use the default Google name servers.

static ip configuration

Static IP configuration

Save the file (Ctrl + S) and Exit (Ctrl + X) when done.

To apply the configurations, we will need to restart the networking service. Execute the command below.

That’s it! You have successfully set a static IP address for your Debian 11 system. Now, when you reboot your system or travel and come back and connect to your WiFi network, the IP address will not change dynamically.

(Method 2) Set up static IP from the GUI

If you are not a command-line person, GNOME (the default Desktop Environment for the Debian system) has provided you with a simple and intuitive interface to configure a static IP address.

First, launch the Settings app from the applications menu and select the ‘Network’ option from the left-hand side panel.

network settings

Network Settings

You can see the network interface you are connected to and the necessary network information from this screen. In our case, we are connected to the ens33 network interface.

To set a static IP address, click on the Settings icon (gear icon) next to the network interface you want to set the static IP address.

network interface settings

Network interface settings

That will open a configuration window where you can perform several network settings. Select the IPv4 tab and in the IPv4 method section, enable the “manual” radio button. A section will appear below where you must fill in the IP address, subnet mask, and Gateway address.

network configurations

Network configurations

Leave the DNS and Routes set as automatic. But if you still want to use your DNS settings and Routes, click on the button next to the ‘Automatic’ tag to enable ‘manual’ mode.

Click the ‘Apply’ button at the top to save the new configurations. To confirm that your static IP address was set successfully, click on the Settings icon next to the network interface and check the ‘details’ section.

confirm configurations

Confirm configurations

That’s it! You have successfully enabled a static IP address from the Graphical User Interface.

This post has given you a step-by-step guide on setting up a static IP address on the Debian 11. We have looked at two methods – setting a static IP via the command line and setting a static IP from the Graphical User Interface. We have also looked at the advantages of using a static IP address and the various scenarios best if you used a static IP. We hope you found this article helpful. If you have any queries or comments, please don’t hesitate to leave a comment below.

You may also like

A ultimate guide to setting up a vsftpd..., your complete guide to installing python on debian, fixing ‘repository does not have a release file’..., fix: ‘unable to locate package’ error in ubuntu..., how to install missing perl modules on debian, how to set up wireguard server on debian.

'  data-srcset=

Thanks. On Raspberry Pi this can be done by adding: ip=192.168.x.xxx to a file in the boot directory that you name: cmdline.txt Are you aware of any similar method that can do this on Debian?

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.

FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

MORE FROM US

  • Ubuntu (307)
  • Downloads (246)
  • Learn Linux (227)
  • Beginner's Guide (170)
  • Terminal Tuts (160)
  • Featured (126)
  • Linux Mint (93)
  • Server (90)
  • Fedora (86)
  • Privacy Policy
  • Terms of Use
  • GDPR Policy
  • Linux Careers

A PART OF VIBRANT LEAF MEDIA COMPANY.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.

  • Beginner’s Guide
  • Terminal Tuts
  • Learn Linux

LinuxWays Logo

How-tos and tutorials for sys admins

How to Set a Static IP on Debian 11

How to Set a Static IP on Debian 11

On a DHCP network, your Linux system will usually receive an IP address automatically from the DHCP server which, in most cases, is the router. The IP configuration will usually comprise the IPv4 address, the netmask, gateway, and the DNS settings. This is usually convenient for desktop or client PCs which only need to access the internet or network resources.

However, the case is different when you want to set up a server. In this case, you would need to configure a static IP to make the server always available via the same IP address. With DHCP, the IP address is bound to change once the lease time is over leading to the unavailability of the server.

In this guide, we will take you through a walk-through of how to set a static IP on Debian 11. We will demonstrate how you can configure a static IP on both the desktop GUI and server instances.

Prerequisites

As you set sail, ensure that you have an instance of Debian 11 server installed and set up. In addition, ensure that you have configured a sudo user.

There are two ways of configuring a static IP on Debian. You can achieve this using GUI or on command-line.

Configure Static IP Address using the Graphical User Interface ( GUI )

If you are running a Debian 11 desktop instance, log in using your username and password. Before we configure the static IP, first confirm the IP address assigned to your system. In our case, we have a Debian PC with an IP address of 192.168.2.104 in a DHCP network.

You can verify this using the command shown.

In our system, enp0s3 interface is the active link that is assigned the IP address. This may be something else in your case.

set static ip address debian command line

To get started with setting the static IP, click on ‘Activities ’ on the left far corner. Search for and click on the ‘ Settings ’ icon.

set static ip address debian command line

On the ‘Settings’ page, select the ‘ Network ’ tab. Next, head over to the ‘Wired’ section and click on the small gear wheel as indicated.

set static ip address debian command line

This displays the current IP address configuration as shown. As we confirmed earlier, our current IP address is 192.168.2.104. This has been dynamically allocated to the active interface using the DHCP service.

We are going to override the DHCP settings and manually set a static IP which will persist even upon a reboot.

set static ip address debian command line

Click the IPv4 tab. Switch from ‘ Automatic ’ to ‘Manual ’ in the IPv4 method section. Thereafter, specify your desired IP address, netmask, and default gateway. Be sure to also provide the preferred DNS settings.

To apply the changes made, click the ‘ Apply’ button.

set static ip address debian command line

You need to restart the networking daemon or service for the Debian system to implement the new static IP settings. So, turn the toggle button off and then on.

set static ip address debian command line

Click on the gear icon once more to verify that the static IP settings have been applied.

set static ip address debian command line

On the terminal, verify that the network interface has acquired the newly configured IP address:

set static ip address debian command line

The output is a confirmation that the system was successfully configured using a static IP. Let’s now shift gears and explore setting a static IP on the command line.

Configure Static IP Address using the terminal

If you are running a headless server, or are connecting to a remote server via SSH, the only option available is to configure the static IP on the command line.

The network configuration settings are stored in the /etc/network/interfaces file. Have a peek at the file as follows. Feel free to use Nano editor if you don’t have vim installed.

By default, only the loopback settings are specified.

set static ip address debian command line

We are going to specify the IP settings for our active network interface. But before making any changes, make a backup of the configuration file.

set static ip address debian command line

Specify the IP settings as provided. Ensure to make your settings in accordance with your network subnet.

set static ip address debian command line

To apply the changes, restart the networking service.

This will disconnect you from the server if you are connected via SSH. Reconnect using the newly set static IP address.

set static ip address debian command line

We have outlined two methods of assigning a static IP on your Debian 11 PC – using GUI and the terminal. The former is the easier option when working on a Debian desktop and the latter comes in handy when configuring a remote server via an SSH client.

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.

  • ← How to Install VirtualBox Guest Additions on Debian 11
  • How to Allow Remote Connections to MySQL →

Similar Posts

Usermod Command with Examples

Usermod Command with Examples

How_to_Install_Manuskript_on_Manjaro_Linux_

How to Install Manuskript on Manjaro Linux?

How to Exclude in Grep Command in Linux

How to Exclude in Grep Command in Linux

How to Set Up a Static IP Address on Debian 12 Linux

A static IP address is already understandable from its name that this IP address will not change. The static IP address is the fixed address that is assigned to a particular network port. 

If one wants to connect to the machine using a remote connection, a static IP address is required for it. If one is connected using the dynamic IP address, then the connection will be interrupted again and again.

Due to this, it is necessary to set up a static IP address on Debian 12, especially when one wants to connect the computer remotely. In this post, the methods for setting up a static IP address on Debian 12 have been explained. 

What are the Methods to Set Up a Static IP Address on Debian 12?

One can set up the static IP address on Debian 12 by using any of the below-mentioned methods:

  • Using the /etc/network/interfaces
  • Using the Network Manager
  • Using the GUI Method

Method 1: Set Up a Static IP Address on Debian 12 Using the /etc/network/interfaces

The first method of setting up the static IP address on Debian 12 is by editing the /etc/network/interfaces file with the text editor. To use the /etc/network/interfaces, follow the next-mentioned steps.

Step 1: Open the Terminal

First, open the terminal to run the commands for setting up the static IP address:

set static ip address debian command line

Step 2: Create a Backup

Create a backup of the original /etc/network/interfaces by copying its contents:

set static ip address debian command line

Step 3: Open the /etc/network/interfaces File

Using the nano or any other text editor, open the /etc/network/interfaces file:

set static ip address debian command line

Step 4: Set Up the Static IP Address

Now find the name of the network interface of which the static IP address is supposed to be set up and assign the IP address:

set static ip address debian command line

After making changes, save the file and close it by using the shortcuts CTRL+S and CTRL+X , respectively.

Step 5: Restart the Network

The final step of this method is to restart the network:

set static ip address debian command line

Method 2: Set Up a Static IP Address on Debian 12 Using the Network Manager

Another method to set up the static IP address on Debian 12 is by using the network manager. For this, follow the steps mentioned below.

Step 1: Use the nmcli Command

With the help of the nmcli command utility, set up the static IP address. To do so, follow the below-mentioned general syntax:

In the above command, change the “Your Connection Name”  with your own values. For example, in our case, the above command will be used like this:

set static ip address debian command line

If the name of the “ connection name ” is not known to you, then use the command:

set static ip address debian command line

Step 2: Reload the NetworkManager

To save the changes, reload the network manager with the command:

set static ip address debian command line

Method 3: Set Up a Static IP Address on Debian 12 Using the GUI

The last but easiest method of setting up the static IP Address on Debian 12 is by using the GUI. The graphical user interface method is to understand, simply open the “ Settings ” of the Debian 12:

set static ip address debian command line

Click on “ Network ” and then choose the “ gear icon ” for the network connection:

set static ip address debian command line

Now click on “ IPv4 ”, then change the address to your own choice, and finally click on the “ Apply ” button:

set static ip address debian command line

The static IP address will be set up successfully. 

How to Verify the Changes to Static IP Address on Debian 12?

To verify the changes to the static IP address on Debian 12, use the command:

set static ip address debian command line

These are the three methods of setting up the static IP address on Debian 12. 

On Debian 12, one can use the “ Network Manager ” or change the “ /etc/network/interfaces ” file to configure the static IP address. Also, access Settings to set the IPv4 address. This post has explained all the mentioned methods with a step-by-step guide.

Maddox

IMAGES

  1. How to Set Static IP Address on Debian 11 (Bullseye)

    set static ip address debian command line

  2. How to Configure Static IP Address on Linux System (2022)

    set static ip address debian command line

  3. How to Set Static IP Address on Debian 11 (Bullseye)

    set static ip address debian command line

  4. How to set static IP Address on Debian 10

    set static ip address debian command line

  5. How to Set Static IP Address on Debian 11 (Bullseye)

    set static ip address debian command line

  6. How to Set Static IP Address on Debian 11 (Bullseye)

    set static ip address debian command line

COMMENTS

  1. How Can Users Find the IP Address of an SMTP Server?

    In the Windows operating system, users can find the IP address of an SMTP server by using the “ping” command and the server’s hostname in the command prompt. The same process is used in the terminal of Unix-based systems such as Linux and M...

  2. Where Is My IP Address Stored on My Computer?

    The location of an IP address is usually found in your computer’s network diagnostics or Internet connection settings. Though this information is stored by your computer, it is assigned by your Internet provider or LAN router.

  3. What Is IP Address 192.168.0.1?

    IP address 192.168.0.1 is the default IP address set in many home routers that are on broadband, particularly the D-Link and Netgear routers. This is set at the factory, but you can go in and change the IP address. It is an IPv4 network add...

  4. How to set up static IP address on Debian Linux 10/11

    How to static IP address on Debian Linux · Open the terminal application. · Log in to remote or server using ssh command. · Backup /etc/network/

  5. How to configure Static IP on Debian 10

    Prerequisites · Step 1: Log in to shell using SSH · Step 2: Find Network Interfaces · Step 3: Find the IP address assigned to the Interface · Step 4: Assign Static

  6. How to set a static IP address on Debian server

    How to set a static IP address in a Debian server ... You should at least see two devices, lo (for loopback) and another named device (such as

  7. NetworkConfiguration

    Setting up an Ethernet Interface ... The majority of network setup can be done via the interfaces configuration file at /etc/network/interfaces.

  8. How to set up a static IP address on Debian 11

    Debian 11 also provides you the facility to set the static IP address of your active network interface using its GUI. If you want to utilize the Debian GUI

  9. Linux Basics: Configuring A Static IP In Debian

    Modifying The Networking Interfaces File ... Most Debian systems use the file /etc/network/interfaces for configuring your network settings.

  10. How to Assign Static IP Address on Debian 12

    Above window shows that Automatic DHCP is enabled, so to Assign Static IP choose 'Manual' and then specify the IP details like IP address

  11. How to set up a static IP address on Debian 11

    To set a static IP address, click on the Settings icon (gear icon) next to the network interface you want to set the static IP address.

  12. Manual Network Configuration in Linux and How to Set a Static IP

    5.1. Add Interface Configuration · auto eth1 enables automatic configuration for this interface during boot · iface eth1 inet static sets eth1

  13. How to Set a Static IP on Debian 11

    Configure Static IP Address using the terminal ... If you are running a headless server, or are connecting to a remote server via SSH, the only

  14. How to Set Up a Static IP Address on Debian 12 Linux

    To set up the static IP address on Debian 12, one can use the “Network Manager” or edit the “/etc/network/interfaces” file.