this post was submitted on 07 Apr 2025
47 points (96.1% liked)

Selfhosted

46304 readers
623 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.

Resources:

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

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

Sorry for being such a noob. My networking is not very strong, thought I'd ask the fine folks here.

Let's say I have a Linux box working as a router and a dumb switch (I.e. L2 only). I have 2 PCs that I would like to keep separated and not let them talk to each other.

Can I plug these two PCs into the switch, configure their interfaces with IPs from different subnets, and configure the relevant sub-interfaces and ACLs (to prevent inter-subnet communication through the router) on the Linux router?

What I'm asking is; do I really need VLANs? I do need to segregate networks but I do not trust the operating systems running on these switches which can do L3 routing.

If you have a better solution than what I described which can scale with the number of computers, please let me know. Unfortunately, networking below L3 is still fuzzy in my head.

Thanks!

you are viewing a single comment's thread
view the rest of the comments
[–] neidu3@sh.itjust.works 3 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

As others have said: It will work as you've planned it. The subnetting will keep these two PCs separated (If they still need internet, just add a second IP in your router-PC to allow for communication with this subnet).

VLANs aren't required, but are more relevant when you want to force network segregation based on individual ports. If you really want to, you can add tagged virtual interfaces on these two separated hosts so that the others hosts aren't able to simply change the address to reach these. The switch should ignore the VLAN tag and pass it through anyway. But again, it's not really needed, just something you can do if you really want to play with tagged VLAN interfaces

[–] marauding_gibberish142@lemmy.dbzer0.com 2 points 2 weeks ago (2 children)

Thank you. In theory, is there a mechanism which will prevent other hosts from tagging the interface with a VLAN ID common with another host and spoof traffic that way? Sorry, I need to study more about this stuff

[–] neidu3@sh.itjust.works 3 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Yes, but that's done on the switch. Basically VLAN tags are applied in one of two ways:

Untagged (sometimes called Access) is something you apply on a switch port. For example, if you assign a port to Untagged VLAN 32, anything connected to that port will only be able to see traffic assigned to VLAN 32.

Tagged (sometimesreferred to as Trunk), on the other hand, is for traffic that is already assigned a VLAN tag. For example Tagged 32 means that it will allow traffic that already has a VLAN tag of 32. It is possible to assign multiple VLANs to a Tagged port. Whatever is connected to that port will need to be able to talk to the associated VLAN(s).

In your particular case, the best practice would be to assign two ports (One for each host, obviously) to Untagged 32 (arbitrarily chosen number, any VLAN ID will do, as long as you're consistent), and all the other ports as Untagged to a different VLAN ID. That way the switch will effectively contain two segments that cannot talk to each other.

[–] marauding_gibberish142@lemmy.dbzer0.com 2 points 2 weeks ago (1 children)

Thank you so much for the explanation. I followed everything but:

Untagged (sometimes called Access) is something you apply on a switch port. For example, if you assign a port to Untagged VLAN 32, anything connected to that port will only be able to connect to port 32.

I couldn't really understand what you meant here. Did you mean VLAN 32 in the last line?

[–] neidu3@sh.itjust.works 1 points 2 weeks ago* (last edited 2 weeks ago)

Derp, yes. Corrected. VLAN numbers are obviously not related to port numbers in any way.

[–] possiblylinux127@lemmy.zip 2 points 2 weeks ago (1 children)

Usually you would configure that on the switch

[–] marauding_gibberish142@lemmy.dbzer0.com 1 points 2 weeks ago (1 children)

I see, I was completely off-track lol. But isn't this really for a setup where each computer is connected to an individual port of the switch? I.E. this won't work if to one port of an L3 switch one were to attach a dumb 5 port switch and plug 4 computers in

[–] possiblylinux127@lemmy.zip 1 points 2 weeks ago (1 children)

https://en.wikipedia.org/wiki/IEEE_802.1Q

Vlans are simply a tag on a frame. You can set what if any tags are allowed and you can set the switch to tag untagged traffic. You can can limit Mac addresses with port security.

[–] marauding_gibberish142@lemmy.dbzer0.com 1 points 2 weeks ago (1 children)

Thank you. Now I just need to learn to do all of this on Linux/BSD lol

[–] possiblylinux127@lemmy.zip 1 points 2 weeks ago (1 children)
[–] marauding_gibberish142@lemmy.dbzer0.com 1 points 2 weeks ago (1 children)

Ooh, would it be similar on other Linux distros/Unixes? I'm trying to decide between Debian, VyOS, Alpine and OpenBSD for my main firewall. All of them have strengths but I think it'll be between VyOS and OpenBSD for me.

[–] possiblylinux127@lemmy.zip 1 points 2 weeks ago

Anything that uses the Linux kernel

I would strongly suggest OpenWRT