Rabu, 05 Februari 2025

Set Static IP on Ubuntu 22.04 with Netplan

Set Static IP on Ubuntu 22.04 with Netplan

How to Set a Static IP Address on Ubuntu 22.04 Using Netplan

1. Identify the network interface

ip a

Note the name of your primary network interface (e.g., eth0 or ens33).

2. Edit the Netplan configuration file

sudo nano /etc/netplan/01-netcfg.yaml

3. Configure a static IP

Modify the file to include your static IP configuration:

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            dhcp4: no
            addresses:
                - 192.168.1.100/24
            gateway4: 192.168.1.1
            nameservers:
                addresses:
                    - 8.8.8.8
                    - 8.8.4.4

Replace eth0 with your actual network interface name.

4. Apply the configuration

sudo netplan apply

5. Verify the changes

ip a

6. Troubleshooting

If there are issues, check for errors with:

sudo netplan try

These are the steps to set a static IP on Ubuntu 22.04 using Netplan. Hope this helps!

Share: