I'm trying to implement a simple internal network (client - router - server) in Ubuntu 21.04 on VirtualBox.
I'm new to Netplan and I have the configuration for Ubuntu previous releases (16.04) with the old /etc/network/interfaces file.
here is the old configurations :
Client :
# The internal interface on neta
auto enp0s8
iface enp0s8 inet static
address 192.168.1.11
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
post-up route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 dev enp0s8
pre-down route del -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 dev enp0s8
Router :
# The internal interface on neta
auto enp0s8
iface enp0s8 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
# The internal interface on netb
auto enp0s9
iface enp0s9 inet static
address 192.168.2.2
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
Server :
# The internal interface on netb
auto enp0s8
iface enp0s8 inet static
address 192.168.2.22
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
post-up route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.2.2 dev enp0s8
pre-down route del -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.2.2 dev enp0s8
I tried to configure the Server, and here is what I did with Netplan :
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s8:
dhcp4: no
addresses:
- 192.168.2.22/24
gateway4: 192.168.2.2
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
- Is my config equivalent to the old one (without specifying netmask, network, broadcast etc..) ?
- For nameservers I did what I saw in a tutorial (8.8.8.8, 8.8.4.4), is it correct in my case ?
- For the Router config in Netplan, do I need a gateway address ? same thing with nameservers ?
Thanks