One NIC... two VLAN's, how to confugure?

digilink

Renowned Member
Jul 31, 2010
9
0
66
Is it possible to run two VLAN's on one physical NIC? I want to use VLAN 1 (10.0.0.0/24) as an admin network, and VLAN 2 (10.0.1.0/24) as a network for the VM's. Is this possible with only one NIC card, and can I use both KVM and OpenVZ guests in this configuration?
 
Is it possible to run two VLAN's on one physical NIC? I want to use VLAN 1 (10.0.0.0/24) as an admin network, and VLAN 2 (10.0.1.0/24) as a network for the VM's. Is this possible with only one NIC card, and can I use both KVM and OpenVZ guests in this configuration?
Hi,
of course you can use many VLANs. You only need allways all VLANs tagged (no default-vlan).
Create for each vlan an brigde - on this bridge you can connect also kvm and openvz-guests.
/etc/network/interfaces
Code:
# network interface settings
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.1
iface eth0.1 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.2
iface eth0.2 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto vmbr1
iface vmbr1 inet static
        address  192.20.10.10
        netmask  255.255.255.0
        gateway  192.20.10.254
        bridge_ports eth0.1
        bridge_stp off
        bridge_fd 0

auto vmbr2
iface vmbr2 inet manual
        bridge_ports eth0.2
        bridge_stp off
        bridge_fd 0
Don't forget to switch on the tagging for both vlans on the switch-side.
(If you go for a cluster use vmbr0 for clustercommunication instead of vmbr1 - but vmbr1 for vlan1 is simple...)

Udo
 
Last edited:
Hi,
of course you can use many VLANs. You only need allways all VLANs tagged (no default-vlan).
Create for each vlan an brigde - on this bridge you can connect also kvm and openvz-guests.
/etc/network/interfaces
Code:
# network interface settings
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.1
iface eth0.1 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.2
iface eth0.2 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto vmbr1
iface vmbr1 inet static
        address  192.20.10.10
        netmask  255.255.255.0
        gateway  192.20.10.254
        bridge_ports eth0.1
        bridge_stp off
        bridge_fd 0

auto vmbr2
iface vmbr2 inet manual
        bridge_ports eth0.2
        bridge_stp off
        bridge_fd 0
Don't forget to switch on the tagging for both vlans on the switch-side.
(If you go for a cluster use vmbr0 for clustercommunication instead of vmbr1 - but vmbr1 for vlan1 is simple...)

Udo

This works... somewhat :( I can not seem to get to the internet in this config however, what am I missing? Here's my /etc/network/interfaces:
Code:
auto lo
iface lo inet loopback


# VLAN
auto eth0
iface eth0 inet static
        address  0.0.0.0
        netmask  0.0.0.0


auto eth0.1
iface eth0.1 inet static
        address  0.0.0.0
        netmask  0.0.0.0


auto eth0.2
iface eth0.2 inet static
        address  0.0.0.0
        netmask  0.0.0.0


auto vmbr0
iface vmbr0 inet static
        address  10.0.0.3
        netmask  255.255.255.0
        gateway  10.0.0.1
        bridge_ports eth0.1
        bridge_stp off
        bridge_fd 0


auto vmbr1
iface vmbr1 inet static
        address  10.0.1.2
        netmask  255.255.255.0
        gateway  10.0.1.1
        bridge_ports eth0.2
        bridge_stp off
        bridge_fd 0
 
Re: One NIC... two VLAN's, how to configure?

This works... somewhat :( I can not seem to get to the internet in this config however, what am I missing? Here's my /etc/network/interfaces:
...
Hi,
looks ok.
BTW: you don't need an ip on the second bridge.

To find the issue, look with tcpdump. I assume that your switch don't tagged the vlan1.
Code:
tcpdump -i eth0 -n | grep 10.0.0.1
during ping 10.0.0.1 should show tagged packets like this:
Code:
10:40:48.281798 vlan 1, p 0, IP 10.0.0.3 > 10.0.0.1: ICMP echo request, id 41656, seq 1, length 64
10:40:48.282045 vlan 1, p 0, IP 10.0.0.1 > 10.0.0.3: ICMP echo reply, id 41656, seq 1, length 64
Udo
 
Re: One NIC... two VLAN's, how to configure?

Finally got this hammered out, thanks for the help :)

The fix was that I had two default gateways, which was causing my problem. Here's my updated /etc/network/interfaces:
Code:
# network interface settings
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.1
iface eth0.1 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.2
iface eth0.2 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto vmbr0
iface vmbr0 inet static
        address  10.0.0.3
        netmask  255.255.255.0
        gateway  10.0.0.1
        bridge_ports eth0.1
        bridge_stp off
        bridge_fd 0

auto vmbr1
iface vmbr1 inet static
        address  10.0.1.2
        netmask  255.255.255.0
        bridge_ports eth0.2
        bridge_stp off
        bridge_fd 0

Once I took the gateway entry out for vmbr1, everything started working as expected.
 
Re: One NIC... two VLAN's, how to configure?

Finally got this hammered out, thanks for the help :)

The fix was that I had two default gateways, which was causing my problem. Here's my updated /etc/network/interfaces:
Code:
# network interface settings
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.1
iface eth0.1 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.2
iface eth0.2 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto vmbr0
iface vmbr0 inet static
        address  10.0.0.3
        netmask  255.255.255.0
        gateway  10.0.0.1
        bridge_ports eth0.1
        bridge_stp off
        bridge_fd 0

auto vmbr1
iface vmbr1 inet static
        address  10.0.1.2
        netmask  255.255.255.0
        bridge_ports eth0.2
        bridge_stp off
        bridge_fd 0

Once I took the gateway entry out for vmbr1, everything started working as expected.

Hi Digilink / Udo,
Thanks for these config. Question: For these portion of the codes
Code:
auto eth0
iface eth0 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.1
iface eth0.1 inet static
        address  0.0.0.0
        netmask  0.0.0.0

auto eth0.2
iface eth0.2 inet static
        address  0.0.0.0
        netmask  0.0.0.0

Can it be changed to these and still get the exact same result?
Code:
auto eth0
iface eth0 inet manual

auto eth0.1
iface eth0.1 inet manual

auto eth0.2
iface eth0.2 inet manual
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!