Score:0

Internal network with Netplan in Ubuntu 21.04

us flag

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

user535733 avatar
cn flag
Line 3: Are you really running NetworkManager (instead of networkd) on the server? NM is big and complex and not usually needed for a simple static IP address.
Geek65 avatar
us flag
Hi, it's Ubuntu Desktop
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.