Convert /etc/network/interfaces to netplan
I'm following this tutorial for making an Ubuntu active directory domain controller with Samba.
The problem I have run into, is that he is using Ubuntu Server 13.10, and I am using the latest, 18.04. Somewhere between these 2 versions, Ubuntu stopped using /etc/network/interfaces
and started using netplan
.
Therefore, when he says to modify /etc/network/interfaces
, and add:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.2.100
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1
dns-nameservers 192.168.1.100 8.8.8.8
dns-search <domain name>.local
I get an error message that says:
ifupdown has been replaced by netplan(5) on this system.
I did some research, and found that now this should be stored in /etc/netplan/01-netcfg.yaml
. This file does not exist. Should I create it? Also, what is the equivalent of what he said to put in the file, for netplan
?
Edit: The output for ls /etc/netplan
is 50-cloud-init.yaml
, and the output for cat /etc/netplan/*.yaml
is:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp0s3:
addresses: []
dhcp4: true
optional: true
version: 2
Solution 1:
First, let’s follow the recommendation included in the 50-cloud-init.yaml file. Please open a terminal and do:
sudo -i
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
exit
Next, let’s remove the file and simultaneously back it up:
sudo mv /etc/netplan/50-cloud-init.yaml ~/50-cloud-init.yaml
Next, verify the ethernet interface name with the command:
ifconfig
Substitute the interface you found below if not enp0s3.
Now let’s write a new file:
sudo nano /etc/netplan/01-netcfg.yaml
Write the following:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
addresses:
- 192.168.2.100/24
gateway4: 192.168.2.1
nameservers:
search: [<domain name>.local]
addresses: [192.168.1.100, 8.8.8.8]
Spacing, indentation, etc. are crucial and must be exact. Proofread carefully twice. Save (Ctrl+o followed by Enter) and exit (Ctrl+x) the text editor.
Now do:
sudo netplan apply
Reboot.