Home >Computer Tutorials >Computer Knowledge >How to set a fixed IP address on Ubuntu 22.04 system.

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

WBOY
WBOYforward
2024-02-20 08:30:03808browse

Ubuntu 22.04系统如何设置固定IP地址。

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

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

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

    network:
      ethernets:
        enp0s3:
          dhcp4: true
      version: 2
  3. Will
    dhcp4: true modified 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 file.
  6. Apply new network configuration:

    sudo netplan apply
  7. Restart 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 ensure that the selected IP address does not conflict with other devices on the network and is configured appropriately according to your network environment.

Please note that depending on the Ubuntu version and network management tool you are using, the location and naming of the network configuration file may change, and corresponding adjustments may be required.

The above is the detailed content of How to set a fixed IP address on Ubuntu 22.04 system.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete