- If it uses NetworkManager:
cat /etc/netplan/01-network-manager-all.yaml :
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager - Determine the Default Gateway:
Use theip routecommand to find out the default gateway of your network, which is essential for configuring your static IP.ip route | grep default | awk '{print $3}' - Setting a Static IP Address:
Replace"WifiName"with your actual connection name. Here’s how you can set a static IP address, gateway, DNS, and switch the method to manual:nmcli con mod "WifiName" ipv4.addresses 192.168.1.10/24nmcli con mod "WifiName" ipv4.gateway 192.168.1.1nmcli con mod "WifiName" ipv4.dns "8.8.8.8"nmcli con mod "WifiName" ipv4.method manual - Applying the Changes:
After setting the static IP, you need to restart the network connection to apply these changes:nmcli con down "WifiName"nmcli con up "WifiName" - Reverting to DHCP (Dynamic IP):
If you encounter any issues or decide to return to using DHCP, you can reset the configuration as follows:nmcli con mod "WifiName" ipv4.method autonmcli con down "WifiName"nmcli con up "WifiName"