Configure Private IPs (BGP networks only)


When working with BGP networks (private networks in Germany and the Netherlands), you may need to manually assign a private IP address to a server.

Depending on the operating system, you can do this using one of the instructions below.

In the examples, we configure the IP address 192.168.0.12/24. Replace it with the address you need.

Ubuntu, Debian 12
Copy link

  1. Check the current network settings:

ip a

The following output indicates that no private IP address is assigned to the eth1 interface (there is no inet field with a private address):

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 54:52:00:f2:d0:09 brd ff:ff:ff:ff:ff:ff
    altname enp0s8
    altname ens8
    inet6 fe80::5652:ff:fef2:d009/64 scope link
        valid_lft forever preferred_lft forever
  1. Open or create a Netplan configuration file:

nano /etc/netplan/99-ipv4.yaml
  1. Add the following configuration:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth1:
      dhcp4: false
      addresses:
        - "192.168.0.12/24"

Here:

    • eth1 is the interface name obtained from ip a.
    • 192.168.0.12 is the private IP address you want to assign.
  1. Restrict permissions on this file so only root can read it:

chmod 600 /etc/netplan/99-ipv4.yaml
  1. Apply the Netplan configuration:

netplan apply
  1. After rebooting, the address may not yet be assigned by the time other services attempt to bind to it. To avoid issues, allow binding to non-local addresses. Open /etc/sysctl.conf:

nano /etc/sysctl.conf
  1. Add the following lines:

net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1
  1. Reload the sysctl configuration:

sysctl -p /etc/sysctl.conf
  1. Restart the networking service:

systemctl restart systemd-networkd
  1. Check the result:

ip a

If the private IP was successfully added, you will see a line with your address, for example:

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 54:52:00:c3:bb:ae brd ff:ff:ff:ff:ff:ff
    altname enp0s8
    altname ens8
    inet 192.168.0.12/24 brd 192.168.0.255 scope global eth1
        valid_lft forever preferred_lft forever
    inet6 fe80::5652:ff:fec3:bbae/64 scope link
        valid_lft forever preferred_lft forever

Debian 11 and earlier
Copy link

  1. Check the current network settings:

ip a

The following output indicates that no private IP address is assigned to eth1:

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 54:52:00:f2:d0:09 brd ff:ff:ff:ff:ff:ff
    altname enp0s8
    altname ens8
    inet6 fe80::5652:ff:fef2:d009/64 scope link
        valid_lft forever preferred_lft forever
  1. Open the network interfaces configuration file:

nano /etc/network/interfaces
  1. Add the following lines:

auto eth1
allow-hotplug eth1
iface eth1 inet static
    address 192.168.0.12/24

Here:

    • eth1 is the interface name obtained from ip a.
    • 192.168.0.12 is the private IP you want to assign.
  1. Allow binding to the address. Open /etc/sysctl.conf:

nano /etc/sysctl.conf
  1. Add these lines:

net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1
  1. Reload the configuration:

sysctl -p /etc/sysctl.conf
  1. Restart the networking service:

systemctl restart networking.service
  1. Check the result:

ip a

You should now see your assigned IP address:

inet 192.168.0.12/24 brd 192.168.0.255 scope global eth1

CentOS
Copy link

  1. Check the current network settings:

ip a

The following output indicates that no private IP is assigned to ens8:

3: ens8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 54:52:00:43:ee:26 brd ff:ff:ff:ff:ff:ff
    altname enp0s8
    inet6 fe80::6f23:a5e7:7cb1:d9d9/64 scope link noprefixroute
        valid_lft forever preferred_lft forever
  1. Add a private IP address to the interface. First, check the connection name:

nmcli connection show
  1. Find the name assigned to ens8 (in this example: Wired connection 1).

Dbb822db 5ffa 4b62 A187 48e133b81b4d.png

  1. Add the private IP to the connection:

nmcli connection modify 'Wired connection 1' ipv4.addresses 192.168.0.12/24

Here, 192.168.0.12 is the private IP you want to assign.

  1. Check that the IP was added:

nmcli connection show 'Wired connection 1' | grep addresses
  1. Disable old configurations. Check the directory:

ls /etc/sysconfig/network-scripts/

If there is a file named ifcfg-ens8, move it elsewhere to disable legacy settings:

mv /etc/sysconfig/network-scripts/ifcfg-ens8 /root/ifcfg-ens8-Backup-$(date +"%Y%m%d")
  1. Ensure the configuration persists after reboot by adding this linet to the 99-disable-network-config.cfg file:

echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
  1. Allow binding to the address. Open the config files:

vi /etc/sysctl.conf
  1. Add these lines:

net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1
  1. Reload the configuration:

sysctl -p /etc/sysctl.conf
  1. Restart NetworkManager:

systemctl restart NetworkManager.service
  1. Check the result:

ip a

You should now see your assigned IP:

inet 192.168.0.12/24 scope global ens8