To configure a static IP address on Ubuntu Server, you can follow these steps:
-
Log in to your Ubuntu Server using the administrator (sudo) account or any other account with administrative privileges.
-
Open a terminal or connect to the server via SSH.
-
Identify the network interface: Use the following command to list the available network interfaces on your server:
ip addr show
Note down the name of the interface you want to configure with a static IP address (e.g., eth0 or ens33).
- Edit the network configuration file: Use a text editor such as Nano or Vim to edit the network configuration file. For example, to use Nano, run the following command:
sudo nano /etc/netplan/00-installer-config.yaml
If you're using a different version of Ubuntu Server, the file path or name may vary. Adjust accordingly.
- Inside the configuration file, locate the network interface you want to configure and modify it to include the static IP configuration. For example, if your interface is named eth0, the configuration might look like this:
network:
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]
version: 2
Replace the IP address (192.168.1.100/24), gateway address (192.168.1.1), and DNS server addresses (8.8.8.8 and 8.8.4.4) with the appropriate values for your network configuration.
-
Save the changes and exit the text editor. In Nano, you can do this by pressing Ctrl+O to save and Ctrl+X to exit.
-
Apply the new network configuration: Use the following command to apply the changes and configure the static IP address:
sudo netplan apply
- Verify the network configuration: Use the following command to check if the static IP address is configured correctly:
ip addr show
You should see the configured IP address assigned to the specified network interface.
- Test the network connectivity: Try pinging a remote server or accessing the internet to ensure that the static IP configuration is working correctly.
By following these steps, you should be able to configure a static IP address on your Ubuntu Server.