How to - dedicated usb wlan interface for container networks, NAT or Bridge?

ljhwild

New Member
Joined
Nov 3, 2022
Messages
20
Reaction score
3
Credits
265
Dear Community
I'm an beginner/intermediate Linux user and I'm working on a project that requires me to launch 4 containers, but they need to be seen by the WIFI router as separate machines.
I've got usb 4 wlan interfaces and I would like to designate one for each container.
My understanding is that I would need to create 4 bridged networks, each bridged to a different interface, and then assign each container to a different bridged network.
However looking at the documentation I didn't see an option to specify interface to bridge to.
I've tried with macvlan networks, but they're so intimidating I have no clue how to set them up. Like which parts of the address I have to acquire from the router, which parts I can just make up?
And how to get it all up properly. I've watched like 10 tutorials and I just don't get it. I understand what's a netmask, but in the network configuriation do I make up a mask, or should I find out the mask of the WiFi network I'm connected to?
I'm on the Uni network, I can connect as many devices as I want but I don't have administrative privilages on the network, so If I requrie any information about the network I'll need to somehow get it myself. Could someone please link up a solution to my problem, or explain how to use the macvlans properly to achieve what I want?
I've been trying for 2 weeks on my own and can't figure it out. Currently I'm running 4 virtual machines to achieve the same result, but the hardware cost is intense, it takes 8gb of ram 4 cores of my CPU just to run some small clients that could be run in a containers instead within the same host.
I appreciate any input and ideas. :)

Edit:
Maybe this will be helpful to figure out the answer
1667484409749.png


1667484715302.png

Can I do a selected if bridges in this case and if not how could I create a ipvlan or macvlan network that uses only this specific interface and is able to connect to the internet?
On my other VM I've got this interface:
1667484516479.png


1667484754987.png


Optimally I'd like to connect both usbs to the same VM and have one USB work for one podman/docker network and the other interface for another network.
How would I go about configuring these subnets, gateway, etc?
THANK YOU :)


Does anyone know? I had a question on stack exchange and I got a confirmation that it's doable in podman, but the question got closed cause it's not related enough to programming. Maybe someone of you also knows? Or is it really as complex as I imagine.
 


There are some things that don't make sense to me here. But first...

What is the output of...

virsh net-list --all

.. and also can you paste the output from ...

virsh net-edit default

.. and finally...

ip link show type bridge

If you simply want four computers on the same network.

Use same gateway for all 4. Use the same netmask for all 4.
It's looks like you have a 24 bit netmask above ( 255.255.255.0 )
I don't see your gateway, I'm assuming it's 192.168.42.1

( netstat -nr will show you )

From the output above, it appears you same IP address on two different VMs.

192.168.42.35. You need to change this on one of the VMs.
Use any address except 35. You can't have two .35's on the same subnet.
Maybe 192.168.42.36 or something.

Bridging in libvirt/KVM is a little bit of a pain. It's easier with VirtualBox, VMware or Proxmox.
But it looks like you aren't running a GUI, so maybe you don't have a choice.

Podman is different from a VM. You assign an IP to a container running a specific application.
But the container doesn't really have a OS on it per se.
 
Thank you so much for taking time to look into my problem and for your reply.
I'll post the screens in a second, in the meantime just to clarify.
I've got a windows pc and a vmware linux instance,
the VM running linux has 4 usb wlan interfaces connected
on that VM I want to run docker or podman
I want to create 4 docker/podman networks
Each network has a dedicated usb wlan interface.
To each network I connect 2-3 containers that need to share public IP
and the IP needs to be different from other sets of 2-3 containers on the other networks.
Like so:
1667562959082.png


Edit the virsh commands don't seem to work on my VM
PLEASE NOTE the testing setup has only 2 usb wlan connectected, but ultimately I want 4, I guess the method off adding more will be analogous to adding 2
and netstat is here
1667563314972.png


and there's an update ifconfig for the two interfaces I want to use
1667563385273.png
 
Last edited:
ifcfg files? How old is this Linux version? No networkManager?

If this is just 4 interfaces on the same VM. Just use the default Podman/Docker subnet
and give each container/NIC it's own unique IP in that subnet.
 
ifcfg files? How old is this Linux version? No networkManager?

If this is just 4 interfaces on the same VM. Just use the default Podman/Docker subnet
and give each container/NIC it's own unique IP in that subnet.
It's latest DebianEdu Standalone, it has a network manager, but I have pretty bad experience with GUI on Linux, there's always something that needs to be done with the console ;p
It's like you said 4 interfaces on the same VM, but when I use a default network all Containers are connected to the same interface via bridge.
If I give each container unique IP within the same subnet they will still share the public IP, won't they?
I want to have 4 different public IPs at my disposal, and be able to decide which container uses which network interface (and therefore which public IP), because each interface will have a different public IP.

The set-up itself is completely flexible, I don't mind choosing a different distro, different VM provider, different Container software, as long as it lets me decide which group of containers gets which public IP a.k.a let me bridge specific Container network to specific interface, or achieve the same thing otherwise.
I.e.
docker-net01 -> bridged to and has the same public IP as usb01 -> container1 and container2 on this network
docker-net02 -> bridged to and has the same public IP as usb02 -> container 3 and container 4 on this network
etc

Alternatively if the problem is very complex can you recommend a specific resource that I can learn (book/chapter/website/tutorial) that would address this somewhat specifically?
 
Last edited:
NetworkManager runs from command line. Most newer Linux's don't use or need the ifcfg files at all.

nmcli dev show
nmcli conn show

nmcli con del enp2s0

nmclli con add con-name eno1 ifname eno1 type ethernet autoconnect yes ip4 192.168.22.11/24 gw4 192.168.22.1 ipv4.method manual

nmcli con mod enp3s0 ipv4.dns '8.8.8.8,9.9.9.9'

This works in redhat, debian, fedora, ubuntu, suse, and most others.
 
Thank you, I will look into this to try to understand what exactly it's doing. But that's a new direction for me with nmcli.
If I do the steppes you listed, will this show as a network I can connect to within Podman?
 
If I give each container unique IP within the same subnet they will still share the public IP, won't they?

With NAT yes, with a true bridge no.
 

Members online


Top