IP and Network Configuration
01
Finding Your Server IP
From the Client Panel
Your server IP is visible in the main panel tab for your server.
From SSH
bash
# IP of all interfaces
ip addr show
# Just the main IP (quick method)
hostname -I | awk '{print $1}'
# Public IP (how the outside sees it)
curl -s ifconfig.me
02
Static Network Configuration
Debian / Ubuntu (Netplan: Ubuntu 18.04+)
Configuration file: /etc/netplan/01-netcfg.yaml
yaml
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
Apply the changes:
bash
netplan apply
Debian (ifupdown: earlier versions)
File: /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 1.1.1.1
Restart networking:
bash
systemctl restart networking
CentOS / AlmaLinux / Rocky Linux
File: /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=1.1.1.1
ONBOOT=yes
Restart networking:
bash
systemctl restart NetworkManager
03
Verify Connectivity
bash
# Test internet connection
ping -c 4 8.8.8.8
# Test DNS resolution
ping -c 4 google.com
# Trace the network path
traceroute 8.8.8.8
# Verify open listening ports
ss -tlnp
04
Adding a Secondary IP (Alias)
If you have an additional IP to add to the server:
bash
# Temporary (lost on reboot)
ip addr add 192.168.1.101/24 dev eth0
# Permanent: add to Netplan or interfaces file
05
Network Interface Name
On modern servers, the interface might be called eth0, ens3, enp1s0, or something else. To see it:
bash
ip link show
Gerelateerde artikelen
