How To Set Up A Static IP Address On Debian 11

When you install a new operating system on your computer, the DHCP server assigns you a dynamic IP address. However, there are various situations where you may need to set up a static IP address on your machine , for example, when you are hosting a web server, or any service that requires an IP address instead of a domain name, or when you are about to grant someone In case of remote access to your system. Whatever the reason, you should know how to set up a static IP address on your system.

In this article, you will learn how to set a static IP on Debian 11 using two different methods . So, let's get started!

Method 1: Set Static IP Address on Debian 11 Using Terminal

As a Debian user, you can easily set a static IP by using the terminal . To do this, first, you must select a valid network interface on your system.

How to Check Available Network Interfaces on Debian 11

You can use the " ip " command to get details of the network interfaces currently available on your system. ip " is an abbreviation for " Internet Protocol ". The ip "command is a tool used by network and system administrators of Linux-based systems to configure network interfaces. In the " ip " command, " link " is a subcommand used to view and modify network interfaces. Write the following command in your Debian 11 terminal to see the currently available network interfaces.

$ ip link
复制代码

From the output, we will note the name of our active network interface, which is " enpos3 ". Because " enpos3 " is the network interface we want to set a static IP on.

How To Set Up A Static IP Address On Debian 11

Now, open the network interface configuration file " /etc/network/interfaces " with nano editor .

$ sudo nano /etc/network/interfaces
复制代码

With default settings, your network interface configuration file will look like this.

In the " /etc/network/interfaces " file, add the following details about your network interface like static IP address , netmask, gateway, dns-nameservers you want to set.

auto enp0s3
iface enp0s3 inet static
address 192.168.2.2
netmask 255.255.255.0
gateway 192.168.2.2
dns-nameservers 8.8.4.4 8.8.8.8
复制代码

这里,前两行声明我们正在为 "enpos3"网络接口设置一个静态IP地址。

要保存你在网络接口配置文件中所作的修改,请按 "CTRL+O"。

如何在 Debian 11 上重新启动网络服务

在为 "enpos3"网络接口配置了静态 IP 地址之后,现在我们将使用systemctl 命令重启网络服务。

$ sudo systemctl restart NetworkManager.service
复制代码

你可以验证你的 Debian 系统是否已经为你选择的网络接口配置了静态 IP。

$ ip a
复制代码

从输出结果中,你可以看到我们已经成功地为 "enpos3"网络接口配置了静态 IP 地址 "192.168.2.2"。

方法2:在Debian 11上使用GUI设置静态IP地址

蝶变11还提供了一个设施,让您可以使用它的图形用户界面来设置您的活动网络接口的静态 IP 地址。如果您想使用 Debian GUI 方法来配置静态 IP 地址,请在应用程序栏中搜索 "设置"来打开您的系统设置。

在左侧菜单中的不同类别中,选择 "网络"。通过点击齿轮图标打开你的活动网络连接的设置。

在打开的网络设置窗口中,点击 "IPv4"标签。为你的网络选择 "手动"IPv4方式。

之后,为你的网络添加你的静态IP地址、网络掩码、网关、DNS,然后点击 "应用"按钮。

现在,打开 "详细信息"标签。在这里,你将验证为你的网络添加的细节,如其IP地址。

这就是你如何在 Debian 11 上使用图形用户界面为你的网络接口设置静态 IP 地址。

总结

蝶变11为您提供了为您的系统 设置静态 IP 地址的选项,无论您是想为您的网络服务器提供主机,还是为任何人提供远程访问。当您安装一个新的操作系统时,DHCP 会自动启用一个动态服务器。然而,您可以使用 Debian 终端和 GUI 来配置您的 IP 地址。在这篇文章中,你已经学会了如何用两种不同的方法在你的 Debian 11 上设置一个静态 IP 地址

Guess you like

Origin blog.csdn.net/muzihuaner/article/details/129077510