This article covers configuring the primary network interface on a server. To add a further address to an existing configuration, see How to add an additional IP address on Linux; for IPv6, see How to configure IPv6.
Use the address, netmask and gateway from your server's details. The examples below use
203.0.113.10, netmask255.255.255.0(/24) and gateway203.0.113.1— these are placeholders, not values that will work on your server.Have console access ready before you begin. A mistake here disconnects SSH, and the console is then the only way back: Managing your CloudVM virtual server in the client area for virtual servers, What is IPMI (IP-KVM) and how do I connect to it? for dedicated ones.
Which section applies
| Operating system | Configured with |
|---|---|
| Ubuntu 24.04 LTS, 22.04 LTS | netplan |
| Debian 13, 12, 11 | ifupdown (/etc/network/interfaces) |
| AlmaLinux 9+, Rocky Linux 9+, RHEL 9+ | NetworkManager (nmcli or nmtui) |
| Windows Server | network adapter properties |
Check the real interface name first — it may be eth0, ens3, enp1s0 or something else:
ip link show
Ubuntu 24.04 / 22.04 (netplan)
Edit the file in /etc/netplan/ — the name varies:
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: no
addresses:
- 203.0.113.10/24
routes:
- to: default
via: 203.0.113.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
Test before applying permanently:
netplan try
This reverts automatically if you do not confirm within a couple of minutes — which is what you want when the change could cut off your own session. Then:
netplan apply
Two things to watch: YAML is indentation-sensitive, and use routes rather than the older gateway4, which is deprecated and produces a warning or is ignored on current releases.
Debian 13 / 12 / 11 (ifupdown)
Edit /etc/network/interfaces:
auto eth0
iface eth0 inet static
address 203.0.113.10
netmask 255.255.255.0
gateway 203.0.113.1
dns-nameservers 1.1.1.1 8.8.8.8
Then:
systemctl restart networking
The gateway option is specified only once across the whole file. Defining it on two interfaces leaves the server without working routing.
AlmaLinux / Rocky Linux / RHEL 9+ (NetworkManager)
The text interface is the simplest route:
nmtui
If it is not installed:
dnf install NetworkManager-tui
Or from the command line:
nmcli connection show nmcli connection modify "System eth0" ipv4.method manual \ ipv4.addresses 203.0.113.10/24 ipv4.gateway 203.0.113.1 \ ipv4.dns "1.1.1.1 8.8.8.8" nmcli connection up "System eth0"
The first command lists the connections so that you use the correct name.
Windows Server
- Open Control Panel → Network and Sharing Center → Change adapter settings.
- Right-click the adapter and choose Properties.
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
- Choose Use the following IP address and enter the address, subnet mask and gateway from your server details.
- Enter the DNS servers, then click OK on each window.
The same can be done from PowerShell, which is often quicker over a console session:
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 203.0.113.10 ` -PrefixLength 24 -DefaultGateway 203.0.113.1 Set-DnsClientServerAddress -InterfaceAlias "Ethernet" ` -ServerAddresses 1.1.1.1,8.8.8.8
Check the result
ip addr ip route ping -c 3 1.1.1.1 ping -c 3 example.com
Work through these in order: the first two show what is configured, the third confirms routing works, and the fourth confirms name resolution. If the third succeeds but the fourth fails, the network is fine and the problem is DNS — see Recommendations for using public DNS resolvers.
Finally, reboot and check again. A configuration that works until the next reboot is a common outcome of editing the wrong file.
If the server loses connectivity and you cannot restore it from the console, open a ticket from your client area.