How to set a fixed IP address in Ubuntu 22.04 system.

To set up a fixed IP address on Ubuntu 22.04, you can follow the steps below:

  1. Open a terminal and edit the network configuration file with administrator privileges:

    sudo nano /etc/netplan/00-installer-config.yaml
    
  2. In the file, you'll see a configuration similar to:

    network:
      ethernets:
        enp0s3:
          dhcp4: true
      version: 2
    
  3. Modify  dhcp4: true to  dhcp4: no, to disable DHCP and enable manual configuration.

  4. Add static IP address configuration, for example:

    network:
      ethernets:
        enp0s3:
          addresses: [192.168.0.100/24]
          gateway4: 192.168.0.1
          nameservers:
            addresses: [8.8.8.8, 8.8.4.4]
      version: 2
    

    Replace  enp0s3 with your network interface name. Specify the fixed IP address, subnet mask, gateway and DNS server address you want to use.

  5. Save changes and close the file.

  6. Apply the new network configuration:

    sudo netplan apply
    
  7. Restart the network service:

    sudo systemctl restart systemd-networkd
    

After completing the above steps, your Ubuntu 22.04 system will use the fixed IP address you specified for network connection. Please make sure that the selected IP address will not conflict with other devices in the network, and configure it properly according to your network environment.

Note that the location and naming of network configuration files may vary between Ubuntu releases and network management tools. Depending on your system and network administration tools, appropriate adjustments may be required.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/131179241