Introduction
This article focuses on a common issue encountered when trying to connect to an Ubuntu server via SSH using a static IP address. The server is outside the DHCP range, and its IP address is a whole-time public IP. In this context, we will discuss the key concepts, subtleties, and solutions to help you resolve the Ubuntu server unreachable via SSH static IP configuration issue.
Understanding the Issue
When setting up a static IP address for an Ubuntu server, it is essential to ensure that the server's IP address is not within the DHCP range. The DHCP range is a pool of IP addresses that the DHCP server assigns dynamically to devices on the network. If the server's IP address falls within this range, it may lead to conflicts and connectivity issues.
Moreover, if the server has a whole-time public IP address, it is not managed by a DHCP server, and you need to manually configure the static IP address on the server to ensure it can be reached via SSH.
Configuring the Static IP Address
Editing the Interfaces File
The first step in configuring a static IP address on an Ubuntu server is to edit the interfaces file. This file is located in the /etc/networking/interfaces/ directory. Use your preferred text editor to edit the file.
sudo nano /etc/networking/interfaces/
Add the following lines to the interfaces file:
auto eth0
iface eth0 inet static
address
netmask
gateway
Replace
Restarting the Networking Services
After saving and closing the interfaces file, restart the networking services to apply the changes:
sudo systemctl restart networking
Testing the Connection
Once the static IP address has been configured, test the SSH connection using the server's IP address:
ssh @
If the connection is successful, you will be prompted to enter your password.
Troubleshooting
If you are still unable to connect to the Ubuntu server via SSH after configuring the static IP address, consider the following:
- Check the server's firewall settings to ensure that SSH is allowed.
- Verify that the server's SSH service is running.
- Check the server logs for any error messages related to SSH.
References
For further reading, consider the following resources: