this post was submitted on 05 Apr 2026
16 points (83.3% liked)

Selfhosted

58273 readers
810 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

  7. No low-effort posts. This is subjective and will largely be determined by the community member reports.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

Hi folks, hope your weekend is going well.

So I have put myself into a situation. I have a home server with docker installed running fine so far. In my home network I have multiple networks for different purposes. The whole network stack looks like this OPNSense


Switch


Ubuntu Server

The server is connected to a switch port with pvid 100, and runs on vlan0.100 Now my goal is to move some docker containers to other vlans. To accomplish that I have set vlan0.101 and vlan0.102 on my server as interfaces with their own IP and default gateway on that subnet (e.g. 192.168.101.10) Next step I set up macvlans for my docker containers Then I set the port to also allow tagged traffic, but kept it on pvid 100. Now on my OPNSense I changed the host ip of my server from 192.168.100.10 to include all 3 IPs so homeserver 192.168.100.10, 192.168.101.10, 192.168.102.10

This setup seems to work fine for internal network, however no services are reachable from the outside (internet) anymore.

My first question is: Am I thinking correctly about this? Or is this over-engineered bs at this point and there is a better way to put docker containers on different subnets.

Second question is: Any ideas what's breaking the internet access?

Thanks for the help in advance :D

EDIT: i have not changed the vlan of any container yet

you are viewing a single comment's thread
view the rest of the comments
[–] probable_possum@leminal.space 2 points 1 day ago* (last edited 1 day ago) (2 children)

I don't think I know the reason for the issue you've described. I don't have enough information for that.

First thing would be: Is the routing and firewalling OK? Later: DNS. Even later: services reachable?

The Opnsense instance has configured multiple VLANs and zones too? With one server interface in each? The packets between the vlans take a path via the router?

I tried to give my server multiple interfaces on different VLANs once, but ran into problems with that approach. I then added one bridge interface per VLAN to the server and gave it just one IP on one vlan. That way the server isn't tempted to route things itself or deliver packets on a wrong interface. An entire class of possible errors was removed that way. Docker containers and VMs still can have IPs in their respective VLANs/ nets.

It is worth noting that docker firewalling and ufw don't play well together, which could be the reason for unreachable services. Moving the docker host into a LXC abstracts the issue away. Incus can run OCI containers itself and may be an alternative to docker (but not docker compose).

I can't say anything about over-engeering. It is a hobby after all and you decide what is important and how much complexity you need. :)

[–] irmadlad@lemmy.world 1 points 1 day ago

It is worth noting that docker firewalling and ufw don’t play well together

This. It took me a little fiddling to get it right

[–] zo0@programming.dev 1 points 1 day ago (2 children)

Answer to your first question, he dockers successfully resolve and access internet

  1. Yes the OPNSense is the primary router and dhcp provider so all the subnets and vlans are defined and working with physical devices

I actually was having the same issue with the routing of server. How did you setup your bridge exactly? Do you mind sharing your netplan?

[–] probable_possum@leminal.space 2 points 1 day ago* (last edited 1 day ago) (1 children)

Netplan config? Sure:

network:
  ethernets:
    enp35s0:
      dhcp4: false
    enp36s0:
      dhcp4: false
  vlans:
    enp35s0.100:
      id: 100
      link: enp35s0
      dhcp4: false
    enp35s0.101:
      id: 101
      link: enp35s0
      dhcp4: false
  bridges:
     br0:
	   # untagged
       interfaces: [enp35s0]
       dhcp4: false
     br0.100:
	   # vlan 100
       interfaces: [enp35s0.100]
       dhcp4: false
     br0.101:
	   #vlan 101
       interfaces: [enp35s0.101]
       dhcp4: true
  version: 2

I'm not sure if the version-property is still required. The only interface with an IP is br0.101. Opnsense provides DHCP (v4).

You can attach multiple ethernet-devices to a bridge (which I did not):

      br0.100:
        interfaces:
          - enp35s0.100
          - two
	        - three

I'm not sure if you can attach the docker bridge via netplan - it has to exist at boot time, I think. My docker containers run inside a VM (kvm) with one interface, which sits in one of the VLANs. The VM's interface is a bridge device (br0.100). The VM ethernet device is attached to the bridge, it receives its IP from the router and behaves like a real server.

[–] zo0@programming.dev 2 points 1 day ago

Thanks for sharing this, I'll give it a try and see how it goes

[–] surewhynotlem@lemmy.world 1 points 1 day ago (1 children)

Bridge? There's your problem I think. Bridge doesn't allow ingress to individual IPs. In bridge, you tell each container what port it listens on, then access it from the IP of the host.

User defined bridges act differently from the default one as well. May not be relevant to your issue, but https://docs.docker.com/engine/network/drivers/bridge/#differences-between-user-defined-bridges-and-the-default-bridge

[–] zo0@programming.dev 1 points 1 day ago (1 children)

I mean at the moment I don't have any bridges setup (other than the dockers own bridge) I thought maybe I could solve my issue with bridging

[–] surewhynotlem@lemmy.world 1 points 1 day ago (1 children)

Oh, hmm. How are you telling which service to be on which IP then? Could you safely post your compose file?

[–] zo0@programming.dev 1 points 1 day ago

I will post it when I get my hands on it, but basically I made a macvlan which is using the server vlan, and then in the compose I set the network to that macvlan, which seems to be functional at least