How to configure a static IP address on Ubuntu?

To set a static IP address on Ubuntu, you can follow these steps:

  1. Open the terminal window and enter the following command to edit the network configuration file:
sudo nano /etc/netplan/00-installer-config.yaml
  1. Locate the “network” section in the editor and add the following content:
network:
  ethernets:
    enp0s3:  # 这里根据您的网络接口名称来替换
      addresses: [192.168.1.100/24]  # 根据您的网络配置来替换
      gateway4: 192.168.1.1  # 根据您的网关地址来替换
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]  # 根据您的DNS服务器地址来替换
      dhcp4: no
  version: 2
  1. Save the changes and close the editor. Then run the following command to apply the changes:
sudo netplan apply
  1. Check if your network connection is working properly. You can view your IP address and network configuration information by running the following command.
ip a

In this way, you have successfully configured a static IP address on Ubuntu.

Leave a Reply 0

Your email address will not be published. Required fields are marked *