I have a wireless usb adapter and I would like my docker container to use just this for the internet (not the computers own wireless adapter). I think I can do this if I know how to access the adapter from a network namespace (because I can create a namespace for the docker container which should then also have access to it).
My knowledge of networking is basic so I have tried to read a lot to work out how to do this but I'm completely out of my depth.
So far I have unsuccessfully tried the following (enx582c80139263 is the usb wireless adapter):
1) create a network namespace and to move the wireless adapter to that (by following this):
sudo ip netns add ns1 sudo ip link set enx582c80139263 netns ns1 sudo ip netns exec ns1 ip address add 10.0.0.1/24 dev enx582c80139263 sudo ip netns exec ns1 ip link set dev enx582c80139263 up
I tried creating a default route for all ip's directly and also with the gateway set as 10.0.0.1, but neither worked:
sudo ip netns exec ns1 route add default enx582c80139263 sudo ip netns exec ns1 route add default gw 10.0.0.1 enx582c80139263
I think I may need to do something with ip routing or iptables for this to work but I'm not sure what.
2) create a network namespace for the container and then creating veth pair, with one veth in the container namespace and the other in global namespace. Then I gave them ip addresses and used a bridge (brctl) to connect the wireless adapter interface to the global namespace veth.
sudo ip netns add ns1 sudo ovs-vsctl add-br br0 sudo ip link add veth0 type veth peer name veth1 sudo ip link set veth0 netns ns1 sudo ovs-vsctl add-port br0 veth1 sudo ovs-vsctl add-port br0 enx582c80139263 sudo ip link set dev veth1 up sudo ip netns exec ns1 ip link set dev veth0 up sudo ip netns exec ns1 ip address add 192.168.1.99/24 dev veth0
I can ping from one veth to the other if I delete the bridge, but can't when the bridge is there. Not sure why, maybe need to change iptables or ip routing.
I may be going about this completely the wrong way...literally learnt about networking and docker in the past few days. Please let me know if I should be approaching this a different way