To assign a static IP address to ens3
interface, edit the file as follows:
- Set DHCP to
dhcp4: no
. - Specify the static IP address. Under
addresses:
you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface. - Specify the gateway.
- Under
nameservers
, set the IP addresses of the nameservers.
/etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: no
addresses:
- 192.168.121.221/24
gateway4: 192.168.121.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
When editing Yaml files, make sure you follow the YAML code indent standards. If the syntax is not correct, the changes will not be applied.
Once done, save the file and apply the changes by running the following command:
sudo netplan apply
Verify the changes by typing:
ip addr show dev ens3
No comments:
Post a Comment