---
title: "Configuring a Private IP Address on a Server | Hostman Docs"
description: "Learn how to configure a private IP address for your Hostman Linux server. Check our step-by-step guides for working with Hostman cloud infrastructure and services."
---

> For the complete documentation index for AI agents, see [llms.txt](https://hostman.com/llms.txt).

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

1.  Check the current network settings:
    

```shell
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):

```yaml
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
```

2.  Open or create a Netplan configuration file:
    

```shell
nano /etc/netplan/99-ipv4.yaml
```

3.  Add the following configuration:
    

```yaml
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.

4.  Restrict permissions on this file so only `root` can read it:
    

```shell
chmod 600 /etc/netplan/99-ipv4.yaml
```

5.  Apply the Netplan configuration:
    

```shell
netplan apply
```

6.  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`:
    

```shell
nano /etc/sysctl.conf
```

7.  Add the following lines:
    

```shell
net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1
```

8.  Reload the `sysctl` configuration:
    

```shell
sysctl -p /etc/sysctl.conf
```

9.  Restart the networking service:
    

```shell
systemctl restart systemd-networkd
```

10.  Check the result:
     

```shell
ip a
```

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

```shell
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

1.  Check the current network settings:
    

```shell
ip a
```

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

```shell
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
```

2.  Open the network interfaces configuration file:
    

```shell
nano /etc/network/interfaces
```

3.  Add the following lines:
    

```shell
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.

4.  Allow binding to the address. Open `/etc/sysctl.conf`:
    

```shell
nano /etc/sysctl.conf
```

5.  Add these lines:
    

```shell
net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1
```

6.  Reload the configuration:
    

```shell
sysctl -p /etc/sysctl.conf
```

7.  Restart the networking service:
    

```shell
systemctl restart networking.service
```

8.  Check the result:
    

```shell
ip a
```

You should now see your assigned IP address:

```shell
inet 192.168.0.12/24 brd 192.168.0.255 scope global eth1
```

## CentOS

1.  Check the current network settings:
    

```shell
ip a
```

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

```shell
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
```

2.  Add a private IP address to the interface. First, check the connection name:
    

```shell
nmcli connection show
```

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

![Dbb822db 5ffa 4b62 A187 48e133b81b4d.png](https://content.hostman.com/assets/33d15a76-52f1-4d76-bde6-f72be7c450bc.png?width=769&height=58)

4.  Add the private IP to the connection:
    

```shell
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.

5.  Check that the IP was added:
    

```shell
nmcli connection show 'Wired connection 1' | grep addresses
```

6.  Disable old configurations. Check the directory:
    

```shell
ls /etc/sysconfig/network-scripts/
```

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

```shell
mv /etc/sysconfig/network-scripts/ifcfg-ens8 /root/ifcfg-ens8-Backup-$(date +"%Y%m%d")
```

7.  Ensure the configuration persists after reboot by adding this linet to the `99-disable-network-config.cfg` file:
    

```shell
echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
```

8.  Allow binding to the address. Open the config files:
    

```shell
vi /etc/sysctl.conf
```

9.  Add these lines:
    

```shell
net.ipv4.ip_nonlocal_bind = 1
net.ipv6.ip_nonlocal_bind = 1
```

10.  Reload the configuration:
     

```shell
sysctl -p /etc/sysctl.conf
```

11.  Restart NetworkManager:
     

```shell
systemctl restart NetworkManager.service
```

12.  Check the result:
     

```shell
ip a
```

You should now see your assigned IP:

```shell
inet 192.168.0.12/24 scope global ens8
```
