In Debian 12, configuring an additional IP address can be done using systemd-networkd or the /etc/network/interfaces file, depending on your network configuration setup.


Method 1: Using systemd-networkd (Recommended for Debian 12)

Step 1: Identify Network Interface

Check your network interface with command:

ip a

 

Step 2: Create or Edit the Network Configuration File

Debian 12 uses systemd-networkd by default. Network configuration files are stored in /etc/systemd/network/.

Create a file like 20-wired.network for your main interface (replace ens33 with your interface name):

sudo nano /etc/systemd/network/20-wired.network

 

Example Configuration:

[Match]
Name=ens33
[Network]
Address=192.168.1.100/24  # Primary IP
Address=192.168.1.101/24  # Additional IP
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4

Step 3: Enable and Restart systemd-networkd

sudo systemctl enable systemd-networkd
sudo systemctl restart systemd-networkd

 

Step 4: Verify Configuration

ip a

Method 2: Using /etc/network/interfaces (Legacy Method)

If you prefer using the legacy method with /etc/network/interfaces, follow these steps:

Step 1: Edit /etc/network/interfaces

Open the network configuration file:

sudo nano /etc/network/interfaces



Example Configuration:

# Primary Interface
auto ens33
iface ens33 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4
# Additional IP
iface ens33:1 inet static
    address 192.168.1.101
    netmask 255.255.255.0



Step 2: Restart Networking Service



Method 3: Temporary Method Using Command Line

If you want to add an IP address temporarily without making it persistent:

sudo ip addr add 192.168.1.101/24 dev ens33

To remove the IP:

sudo ip addr del 192.168.1.101/24 dev ens33

Verification

Check if the additional IP is configured correctly:

ip a

 

Troubleshooting Tips

  1. Check Status: If it doesn't work, check the network status:

sudo systemctl status systemd-networkd





Was this answer helpful? 0 Users Found This Useful (0 Votes)