Step 1: Connect to your VPS
- Open your terminal or SSH client (e.g., PuTTY for Windows).
- Use the SSH command to connect to your VPS using your username and IP address:
ssh your_username@your_vps_ip_address
Step 2: Edit the Network Configuration File
- Use a text editor like Nano to open the network configuration file:
bash
sudo nano /etc/netplan/50-cloud-init.yaml
Step 3: Identify the Current IP Configuration
- Look for the current IP address configuration in the file. It will resemble something like this:
network: version: 2 ethernets: eth0: addresses: - 192.168.1.100/24 gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8, 8.8.4.4]
Step 4: Update the IP Address
- Replace the existing IP address with the new static IP address you want to use. Make sure to keep the correct subnet mask and gateway address if required by your network configuration.
Step 5: Save and Apply the Changes
- Press
Ctrl + O
to save the changes in Nano. - Press
Ctrl + X
to exit Nano. - Apply the changes to the network configuration:
sudo netplan apply
Step 6: Verify the New IP Address
- Check the new IP address using the
ip
command:ip address show eth0
Step 7: Restart the Networking Service (Optional)
- For some systems, it might be necessary to restart the networking service to apply the changes:
sudo systemctl restart networking
Step 8: Test Connectivity
- Verify that your VPS can still connect to the internet and other devices.
Congratulations! You have successfully changed the static IP address on your VPS running Ubuntu 18.