Wifi – Proxmox with an Openvswitch bridge

bridgenetworkingopenvswitchproxmoxwifi

All,

I'm trying create a way for me to be able to use the local network within my Proxmox infrastructure.

Currently, everything is running off of NAT from wlan0 and all internal machines have the same local IP address — which is not very useful to me at all. I'm trying to fix this with ovs.

My ovs setup:

[wlan0] [IP Stack]
  |      |
[maplebridge] -- vport1
              -- vport2 

My ovs config:

ovs-vsctl add-br maplebridge #Create my bridge
ip link set maplebridge up # Turn on bridge
ovs-vsctl add-port maplebridge wlan0 # Add wlan0
ip addr del 192.168.1.136/24 dev wlan0 # Remove config from wlan0
dhclient maplebridge # DHCP IP addr to maplebridge
ip tuntap add mode tap vport1 # Create vport1
ip tuntap add mode tap vport2 # Create vport2
ip link set vport1 up # Turn on vport1
ip link set vport2 up # Turn on vport2
ovs-vsctl add-port maplebridge vport1 -- add-port maplebridge vport2 # Add ports to bridge

ovs settings:

root@henesys:/home/mztriz# ovs-vsctl show
55601e1b-928a-454b-9e7f-d5c24ed47fe9
    Bridge maplebridge
        Port maplebridge
            Interface maplebridge
                type: internal
        Port "vport2"
            Interface "vport2"
        Port "vport1"What 
            Interface "vport1"
        Port "wlan0"
            Interface "wlan0"
    ovs_version: "2.3.0"

Contents of /etc/network/interfaces:

root@henesys:/home/mztriz# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static
    address  192.168.1.136
    netmask  255.255.255.0
    gateway  192.168.1.1
    wpa-ssid ""
    wpa-psk ""

allow-ovs maplebridge
iface maplebridge inet dhcp
    ovs_type OVSBridge
    ovs_ports vport1 vport2

allow-br0 vport1
iface vport1 inet manual
    ovs_bridge vport1
    ovs_type OVSPort

allow-br0  vport2
iface vport2 inet manual
    ovs_bridge vport2
    ovs_type OVSPort

This is what I see in the web interface under Network:
enter image description here

This is what happens if I try to set one of my VMs to use the network adapter vport1:
enter image description here

As you can see I can't attach vports 1 or 2 to any of my VMs. How does this setup work in Proxmox?

EDIT:

It was suggested to me to try NAT over NAT with an ovs bridge created from the Proxmox web GUI as follows:

Make a new subnet (e.g. 192.168.2.0/24) inside of Proxmox, i.e. remove "wlan0" from the "maplebridge".

All VMs should be connected with one virtual LAN, but not with wlan.

The traffic has to be routed via internal NAT in Proxmox, the NAT has to be activated when the bridge starts up (to be added in /etc/network/interfaces):

auto vmbr1
iface vmbr1 inet static
    address  192.168.1.136
    netmask  255.255.255.0
    ovs_type OVSBridge
    pre-up iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o wlan0 -j MASQUERADE

However, if I do this wouldn't the addresses from wlan0 and vmbr1 conflict since they're the same?

When I use this configuration I cannot get any connectivity in the 192.168.2.0/24 subnet cross VMs or outside. I am able to select vmbr1 for the VMs to use in their network interfaces but again they can only ping local host or their assigned IPs.

Best Answer

I got the internal VM network working.

Added OVS Bridge vmbr1 to Proxmox and changed /etc/network/interfaces to the following:

auto wlan0
iface wlan0 inet static
        address  192.168.1.136
        netmask  255.255.255.0
        gateway  192.168.1.1
        wpa-ssid ""
        wpa-psk ""

auto vmbr1
iface vmbr1 inet static
    address  10.0.2.1
    netmask  255.255.255.0
    ovs_type OVSBridge
    pre-up iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o wlan0 -j MASQUERADE

I then assigned the network device vmbr1 to my VMs and configured each VM with a static IP in the 10.0.2.x network. Then I enabled ipv4 forwarding in sysctl.conf on the VMs and Proxmox host.

/etc/sysctl.conf:
net.ipv4.ip_forward = 1

Internal and external networks are both working now!