To set a static IP address on Ubuntu, you can follow the steps below. This example assumes Ubuntu 20.04; please adjust the steps accordingly for your specific Ubuntu version.
1. Identify Network Interface:
- Check Network Interfaces:
- Open a terminal and run the following command to find your network interface name (typically
eth0
orenpXsX
):ip a
- Open a terminal and run the following command to find your network interface name (typically
2. Set Static IP Address:
- Edit Netplan Configuration File:
- Open a text editor using the following command (you can use
nano
or any text editor of your choice):sudo nano /etc/netplan/00-installer-config.yaml
- Open a text editor using the following command (you can use
- Edit Netplan Configuration:
- Edit the file content as follows:
network: version: 2 renderer: networkd ethernets: your_interface_name: # Add your interface name here (e.g., eth0) dhcp4: no addresses: [your_static_ip/your_subnet_mask] gateway4: your_gateway nameservers: addresses: [your_dns_server]
- Fill in the variables:
your_interface_name
: Your network interface name.your_static_ip
: Your desired static IP address.your_subnet_mask
: Subnet mask.your_gateway
: Default gateway.your_dns_server
: DNS server’s IP address.
- Edit the file content as follows:
- Apply Netplan Configuration:
- Apply the Netplan configuration by running:
sudo netplan apply
- Apply the Netplan configuration by running:
3. Verify Network Settings:
- Check Network Settings:
- Verify the network settings using the following command:
ip a
- Ensure that your network interface lists the new static IP address.
- Verify the network settings using the following command:
- Check Internet Connection:
- Test the internet connection using a web browser or the
ping
command:ping google.com
- If the ping is successful, your internet connection is working correctly.
- Test the internet connection using a web browser or the
By following these steps, you can set a static IP address on Ubuntu. Note that you may need to restart network services or the network interface for the changes to take effect.