Ubuntu 22 uses Netplan to manage network settings by default. You can modify the static IP via the command line, and the desktop version also allows for graphical interface operations. The detailed tutorial is as follows:
Command Line Method (Applicable for Server/Desktop Versions)
1. Check the network interface name: Open the terminal and enter ip a, then note the interface name (e.g., ens33, enp0s3).
2. Edit the Netplan configuration file: The configuration file is located in the /etc/netplan/ directory. Execute sudo nano /etc/netplan/00-installer-config.yaml (the filename may vary; you can use ls /etc/netplan/ to check).
3. Write the IP configuration: Modify the existing content to set the static IP configuration, as shown below (replace the interface name, IP, etc., with actual information):
network: version: 2 ethernets: ens33: # Replace with your interface name dhcp4: no # Disable DHCP addresses: [192.168.1.100/24] # Static IP and subnet mask routes: - to: default via: 192.168.1.1 # Gateway nameservers: addresses: [8.8.8.8, 114.114.114.114] # DNS
4. Apply the configuration: Press Ctrl+X, Y to save and exit, then execute sudo netplan apply to make the configuration effective.
Graphical Interface Method for Desktop Version
1. Click the network icon in the upper right corner of the screen and select Settings.
2. In the pop-up window, find the corresponding network connection and click the gear icon on the right.
3. Switch to the IPv4 tab, change the “Method” to Manual, and fill in the address, subnet mask, gateway, and DNS.
4. Click Apply, disconnect, and then reconnect to the network to make it effective.