Netplan: Set static IP address

In order to set a static IP address to an interface using Netplan, we have to edit the desired Netplan yaml file.

Here is an example for configuring the interface eth0 with a static IP address.

network:
version: 2
renderer: networkd
eth…


This content originally appeared on DEV Community and was authored by Sergio Peris

In order to set a static IP address to an interface using Netplan, we have to edit the desired Netplan yaml file.

Here is an example for configuring the interface eth0 with a static IP address.

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            dhcp4: false
            dhcp6: false
            addresses:
                - 192.168.1.100/24
            routes:
                - to: default
                  via: 192.168.1.1
            nameservers:
                addresses: [1.1.1.1, 8.8.8.8]

Here we're setting the IP 192.168.1.100 as the static IP, 192.168.1.1 as the gateway, 1.1.1.1 and 8.8.8.8 as the DNS servers.

To apply the changes, we should run the command:

netplan apply


This content originally appeared on DEV Community and was authored by Sergio Peris


Print Share Comment Cite Upload Translate Updates
APA

Sergio Peris | Sciencx (2025-02-17T08:04:26+00:00) Netplan: Set static IP address. Retrieved from https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/

MLA
" » Netplan: Set static IP address." Sergio Peris | Sciencx - Monday February 17, 2025, https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/
HARVARD
Sergio Peris | Sciencx Monday February 17, 2025 » Netplan: Set static IP address., viewed ,<https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/>
VANCOUVER
Sergio Peris | Sciencx - » Netplan: Set static IP address. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/
CHICAGO
" » Netplan: Set static IP address." Sergio Peris | Sciencx - Accessed . https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/
IEEE
" » Netplan: Set static IP address." Sergio Peris | Sciencx [Online]. Available: https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/. [Accessed: ]
rf:citation
» Netplan: Set static IP address | Sergio Peris | Sciencx | https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.