1

My goal is to configure the machine so that I can have multiple nspawn containers that can talk out to the Internet, the host must be able to talk out to the Internet, and from the host I must be able to connect the the containers via ip - the containers will be running web servers.

The problem is that things look like they are sort of configured OK but I cannot ping the machine from the Internet and when I am signed in to the machine it cannot talk out to the Internet.

The question: how can I configure this to talk to the Internet?

This is a virtual machine running on Oracle cloud, which says:

Public IPv4 address: 192.9.139.126 Private IPv4 address: 10.0.0.214

I am trying to change from a netplan configuration to a configuration using systemd networkd files.

This netplan config worked fine:

ubuntu@instance-20240106-1821:~$ cat /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  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:
    version: 2
    ethernets:
        ens3:
            dhcp4: true
            match:
                macaddress: 02:00:17:00:2a:9c
            set-name: ens3
ubuntu@instance-20240106-1821:~$ 

But now that I have disabled the above and implemented by systemd networkd config i cannot communicate in or out to the Internet.

Here is my networkd config:

ubuntu@instance-20240106-1821:~$ cat /etc/systemd/network/br0.network

[Match]
Name=br0

[Network]
DHCP=no
Address=10.0.0.214/24
Gateway=10.0.0.1

ubuntu@instance-20240106-1821:~$ cat /etc/systemd/network/br0.netdev

[NetDev]
Name=br0
Kind=bridge

[Bridge]
MACAddress=02:00:17:00:2a:9c

ubuntu@instance-20240106-1821:~$ cat /etc/systemd/network/ens3.network

[Match]
Name=ens3

[Network]
Bridge=br0

ubuntu@instance-20240106-1821:~$ sudo networkctl status ens3

● 2: ens3                                                                      
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/ens3.network
                          Type: ether
                         State: enslaved (configured)
                  Online state: online                                         
             Alternative Names: enp0s3
                          Path: pci-0000:00:03.0
                        Driver: virtio_net
                        Vendor: Red Hat, Inc.
                         Model: Virtio network device
                    HW Address: 02:00:17:00:2a:9c
                           MTU: 9000 (min: 68, max: 65535)
                         QDisc: pfifo_fast
                        Master: br0
  IPv6 Address Generation Mode: none
          Queue Length (Tx/Rx): 1/1
              Auto negotiation: no
                         Speed: n/a
             Activation Policy: up
           Required For Online: yes

Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: ens3: Link UP
Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: ens3: Gained carrier
Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: ens3: Gained IPv6LL

ubuntu@instance-20240106-1821:~$ sudo networkctl status br0

● 3: br0                                                                       
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/br0.network
                          Type: bridge
                         State: routable (configured)
                  Online state: online                                         
                        Driver: bridge
                    HW Address: 5e:37:61:dc:ab:83
                           MTU: 9000 (min: 68, max: 65535)
                         QDisc: noqueue
  IPv6 Address Generation Mode: eui64
                 Forward Delay: 15s
                    Hello Time: 2s
                       Max Age: 20s
                   Ageing Time: 5min
                      Priority: 32768
                           STP: no
        Multicast IGMP Version: 2
                          Cost: 2000
                    Port State: disabled
          Queue Length (Tx/Rx): 1/1
              Auto negotiation: no
                         Speed: n/a
                       Address: 10.0.0.214
                                fe80::5c37:61ff:fedc:ab83
                       Gateway: 10.0.0.1
             Activation Policy: up
           Required For Online: yes
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab110e53ac1395c0e1110000

Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: br0: netdev ready
Jan 06 08:59:08 instance-20240106-1821 systemd-networkd[526]: br0: Link UP
Jan 06 08:59:09 instance-20240106-1821 systemd-networkd[526]: br0: Gained carrier
Jan 06 08:59:11 instance-20240106-1821 systemd-networkd[526]: br0: Gained IPv6LL
ubuntu@instance-20240106-1821:~$ 

ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 02:00:17:00:2a:9c brd ff:ff:ff:ff:ff:ff
    altname enp0s3
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP group default qlen 1000
    link/ether 5e:37:61:dc:ab:83 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.214/24 brd 10.0.0.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::5c37:61ff:fedc:ab83/64 scope link 
       valid_lft forever preferred_lft forever
ubuntu@instance-20240106-1821:~$ 

2 Answers 2

1
[NetDev]
Name=br0
Kind=bridge

[Bridge]
MACAddress=02:00:17:00:2a:9c

MACAddress= is only documented for the [NetDev] section, not the [Bridge] section of a *.netdev file. Alternatively you could add a [Link] section to your br0.network file and put it in there.

Currently it seems to get ignored, and your bridge is getting a generated MAC address:

● 3: br0                                                                       
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/br0.network
                          Type: bridge
                         State: routable (configured)
                  Online state: online                                         
                        Driver: bridge
                    HW Address: 5e:37:61:dc:ab:83   <---!!!

So you should either change your br0.netdev file to:

[NetDev]
Name=br0
Kind=bridge
MACAddress=02:00:17:00:2a:9c

[Bridge]

Or alternatively, you could entirely remove the MacAddress=02:00:17:00:2a:9c line from the br0.netdev file, and place it into br0.network file instead, in the [Link] section:

[Match]
Name=br0

[Link]
MACAddress=02:00:17:00:2a:9c

[Network]
DHCP=no
Address=10.0.0.214/24
Gateway=10.0.0.1
3
  • Thanks for the reply - not quite sure I understand - what changes do I need to make? thanks! Commented Jan 6 at 10:24
  • Thanks for your help - it appears to have been caused by DHCP in fact being needed rather than static. Commented Jan 6 at 11:53
  • 1
    You're probably correct: the DHCP server is probably connected to Oracle's cloud management systems. However moving the MACAddress line to where it actually works may have helped too, in ensuring the DHCP request will be made using the expected MAC address.
    – telcoM
    Commented Jan 6 at 13:21
1

In the end I think the problem was that it had to be DHCP=yes

After changing br0.network to:

[Match]
Name=br0

[Network]
DHCP=yes
#Address=10.0.0.214/24
#Gateway=10.0.0.1
DNS=8.8.8.8

[Link]
MACAddress=02:00:17:00:4a:bc

I got:

ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 02:00:17:00:4a:bc brd ff:ff:ff:ff:ff:ff
    altname enp0s3
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP group default qlen 1000
    link/ether 02:00:17:00:4a:bc brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.209/24 metric 1024 brd 10.0.0.255 scope global dynamic br0
       valid_lft 86351sec preferred_lft 86351sec
    inet6 fe80::17ff:fe00:4abc/64 scope link
       valid_lft forever preferred_lft forever

and hey presto:

ubuntu@instance-20240106-2021:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=61 time=1.72 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=61 time=1.75 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=61 time=1.74 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=61 time=1.78 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=61 time=1.75 ms
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 1.718/1.746/1.775/0.018 ms
ubuntu@instance-20240106-2021:~$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .