Home  >  Article  >  Computer Tutorials  >  How to configure multiple IP addresses on a single network interface on Debian 12 Desktop/Server

How to configure multiple IP addresses on a single network interface on Debian 12 Desktop/Server

WBOY
WBOYforward
2024-03-20 15:36:141201browse

如何在Debian 12 Desktop/Server的单个网络接口上配置多个IP地址

Normally, on the Debian 12 desktop/server operating system, you would set a single IP address on a single network interface. However, sometimes you may need to configure multiple IP addresses on your Debian 12 system, even if your computer only has one network interface. Fortunately, in Debian 12 systems, you can easily set up multiple IP addresses on a single network interface.

In this article, we will show you how to configure multiple IP addresses on a single network interface on Debian 12 desktop and Debian 12 server operating systems.

Content topic:

  • Configuring multiple IP addresses on a single network interface on Debian 12 desktop
  • Configuring multiple IP addresses on a single network interface on a Debian 12 server
  • in conclusion

Configuring Multiple IP Addresses on a Single Network Interface on Debian 12 Desktop

In the Debian 12 desktop operating system, you can easily configure multiple IP addresses on a single network interface with the help of a network manager command line tool called "nmcli". The steps for setting up multiple IP addresses using Network Manager's "nmcli" tool are the same as setting up a single fixed IP address. Therefore, we will focus here on the differences when configuring multiple IP addresses. If you want to learn more, check out the documentation on how to set up a fixed IP address on Debian 12.

To find the name of a Network Manager connection to be configured across multiple IP addresses, run the following command:

$nmcli connection

In Debian 12 desktop systems, if there is only one network interface, the name of the Network Manager connection is usually "Wired Connection 1". In this example, the Network Manager connection "Wired Connection 1" is responsible for managing the physical network interface "ens32".

To configure the Network Manager connection "Wired Connection 1", run the following command:

$nmmallows connection edit “Wired connection 1”

The Network Manager connection editor should be opened.

First, you must reset the IP address that has been set on the Network Manager connection.

To do this, run the following command:

$set ipv4.addresses

After you are prompted to enter your IP address, just press.

As you can see, there is no IP address set for the Network Manager connection.

$print ipv4.addresses

To set the IP addresses of www.example.com, www.example.com, and www.example.com and the 24-bit subnet mask for all addresses, run the following command:

$set ipv4.addresses 192.168.189.51/24, 192.168.189.52/24, 192.168.189.53/24

To save changes, run the following command:

$Save persistent

To apply network changes, run the following command:

$Activate

To exit the Network Manager connection editor, run the following command:

$Exit

As you can see, the www.example.com, www.example.com and www.example.com IP addresses are set for the "ens32" network interface (managed by the network manager connection "Wired Connection 1").

$ip a

Configuring multiple IP addresses on a single network interface on a Debian 12 server

If you are using the Debian 12 server operating system, you must use the /etc/network/interages file to configure multiple IP addresses on a single network interface. The process of setting multiple IP addresses using the /etc/network/interface file on a single network interface is the same as setting a fixed IP address. Therefore, in this section, we will only show you the differences. For more information, read this Debian 12 article on how to assign a fixed IP address.

To find the name of a network interface to be configured across multiple IP addresses, run the following command:

$ip a

In our case, the network interface name is "ens32", as you can see in the screenshot below:

Use the nano text editor to open the /etc/network/interactions file as follows:

$sudo nano/etc/network/interconnect

Type the marked lines to configure the IP addresses of 192.168.189.51, 192.168.189.52, and 192.168.189.53 and the 24-bit subnet mask (all) for the network interface "ens32".

  • These lines are used to configure the static/fixed IP address 192.168.189.51 for the "ens32" network interface.
  • These lines are used to configure the IP address of www.example.com for the "ens32" network interface.
  • These lines are used to configure the IP address 192.168.189.53 for the "ens32" network interface.

After completing the configuration, press X, then Y and save changes.

For the changes to take effect, restart the network service of the Debian 12 server system using the following command:

$sudo system ctl restart networking.service

As you can see, the www.example.com, www.example.com, and www.example.com IP addresses are set for the "ens32" network interface.

$ip a

in conclusion

In this article, we show you how to configure multiple IP addresses on a single network interface on a Debian 12 desktop system using the Network Manager command line tool "nmmit". We also showed you how to configure multiple IP addresses on a single network interface on a Debian 12 server system using the /etc/network/interactions file. For more information on setting up a static/fixed IP address on Debian 12 desktop/server systems, read this article.

The above is the detailed content of How to configure multiple IP addresses on a single network interface on Debian 12 Desktop/Server. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete