During a precent project, I was setting up a VM with multiple network interfaces, but the interface I added wasn't up.
Ensure the interface is up #
# Up interface
sudo ifconfig <interface_name> up
# Request IPv4 address
sudo dhclient <interface_name>
ip a
Ensure the interface is up at boot #
For that, we need to update netplan configuration.
Add interface to config file #
Create or open /etc/netplan/01-netcfg.yaml
If you create it, permissions should be sudo chmod 0600 /etc/netplan/01-netcfg.yaml
sudo nano /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
enp0s3:
dhcp4: yes
# add interface you want below
INTERFACE_NAME:
dhcp4: yes
Apply the changes #
sudo netplan apply
Remove an IP address for an interface #
sudo ip addr del <IP ADDRESS> dev <INTERFACE>