Configuring the network on an Ubuntu VPS server is crucial for ensuring the server's availability on the Internet. This guide outlines the key steps for network setup on a VPS server, including configuring a static IP address, setting up DNS, and performing basic network diagnostics.
Step 1: Connect to the Server
The first step is to connect to your VPS server via SSH. Use the following command:
ssh username@your_server_ip
Here, username
is your username on the server, and your_server_ip
is the IP address of your server.
Step 2: Check Current Network Settings
Before making changes, it's useful to check the current network settings. Execute the following command:
ip addr show
This command will display the current network interfaces and their IP addresses.
Step 3: Configure a Static IP Address
To set up a static IP address on Ubuntu, you'll use the configuration file /etc/netplan/*.yaml
. Open this file for editing (the filename may vary, e.g., 01-netcfg.yaml
):
sudo nano /etc/netplan/01-netcfg.yaml
Here's an example configuration for a static IP address:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
After making changes, save the file and apply the new configuration:
sudo netplan apply
Step 4: Configure DNS Servers
To change DNS server settings, open the /etc/netplan/*.yaml
file and add or modify the nameservers
section as shown in the example above. After changing the configuration, apply it:
sudo netplan apply
Step 5: Diagnose Network Issues
To troubleshoot network issues, use the following commands:
-
ping: Check the availability of a host.
bashping 8.8.8.8
-
traceroute: Trace the route to a host.
bashtraceroute google.com
-
nslookup: Check DNS queries.
bashnslookup google.com
-
netstat: View network connections.
bashnetstat -tuln
Configuring the network on an Ubuntu VPS involves several key steps, from setting up a static IP address to configuring DNS and troubleshooting network issues. These steps help ensure the stability and availability of your server on the Internet.