Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default rules conflict with DHCP #35

Closed
eliasp opened this issue Jul 28, 2015 · 5 comments
Closed

Default rules conflict with DHCP #35

eliasp opened this issue Jul 28, 2015 · 5 comments
Labels
won't fix Won't fix. Out of scope or not useful.

Comments

@eliasp
Copy link

eliasp commented Jul 28, 2015

It looks like the default rules conflict with systemd-networkd's builtin DHCP server.

How to reproduce:

  • Run a system with:

    • firewalld (e.g. Fedora 22)
    • systemd 219 (or newer)
  • Launch a new systemd-nspawn container with veth networking:

    systemd-nspawn --network-veth -bxD /var/lib/machines/centos7.1-base

What should happen:

  • systemd-nspawn creates the network interface ve-centos71-b

  • systemd-networkd running on the host picks up the network interface and configures it according to the configuration below (including running a minimal DHCP server to hand out IP configurations to containers):

    [Match]
    Name=ve-*
    Driver=veth
    
    [Network]
    # Default to using a /28 prefix, giving up to 13 addresses per container.
    Address=0.0.0.0/28
    LinkLocalAddressing=yes
    DHCPServer=yes
    IPMasquerade=yes
  • systemd-networkd running in the container configures the interface host0 inside the container based on the configuration below:

    [Match]
    Virtualization=container
    Name=host0
    
    [Network]
    DHCP=yes
    LinkLocalAddressing=yes

What happens instead:

  • The host0 interface in the container never receives a DHCP configuration from the DHCP server running on the host because the requests/responses are blocked by firewalld on the host

Stopping firewalld temporarily "fixes" the issue and shows that firewalld is the "culprit" in this case.

Although I'm not quite sure yet, how the policy would have to look like exactly, I think this should be probably covered by firewalld's default configuration.

@t-woerner
Copy link
Collaborator

Only dhcpdv6-client is enabled by default in the firewall, as this is essential for mostly all clients using IPv6.
You can simply enable the dhcp service in your configuration to allow access to the dhcp server provided by systemd-networkd. If systemd-networkd is also providing a dhcpv6 server, then also enable dhcpv6.

@npmccallum
Copy link

The problem is that this breaks systemd-nspwan containers:
systemd/systemd#2552

The default policy needs to not break systemd on ve-* interfaces.

@sourcejedi
Copy link

I agree there's a conflict, but I'd like to note it goes beyond DHCP. Containers launched with systemd-nspawn -n are also intended to have internet access, e.g. for dnf.

(The default config for systemd-networkd enables ipv4 masquerading for this).

After allowing access to DHCP in firewalld, you get an address, but internet-bound packets are rejected as "administratively prohibited":

# traceroute 8.8.8.8   
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  gateway (10.0.0.1)  0.091 ms  0.031 ms  0.026 ms
 2  gateway (10.0.0.1)  0.033 ms !X  0.028 ms !X  0.028 ms !X

@SadPencil
Copy link

sudo firewall-cmd --add-service=dhcp

I think this issue could be closed.

@erig0
Copy link
Collaborator

erig0 commented Apr 29, 2019

The default policy needs to not break systemd on ve-* interfaces.

Firewalld upstream is not going to allow DHCP server by default. That can either be done statically by the distribution, or at runtime by the container startup.

After allowing access to DHCP in firewalld, you get an address, but internet-bound packets are rejected as "administratively prohibited":

Firewalld filters forwarded packets by default. You can add the container's interface to the trusted zone to remedy this.

@erig0 erig0 closed this as completed Apr 29, 2019
@erig0 erig0 added not a bug Not a bug. Works as designed. won't fix Won't fix. Out of scope or not useful. and removed not a bug Not a bug. Works as designed. labels Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
won't fix Won't fix. Out of scope or not useful.
Projects
None yet
Development

No branches or pull requests

6 participants