I'm trying to setup a working connection between my local network and the internet.
First I setup a bridge (br0, has an IP address where the other interfaces don't) between eth0 (LAN) and eth1 (internet), and created a nat rule in iptables to masquerade the source ip of the local ip's in the LAN.
Everything works great and I can access the internet from subnet 192.168.1.0.
Now I want to create two vlan's: 100 and 200.
I tried using vconfig to create eth0.100 and eth0.200 but I can't figure out how to connect them the internet. Packets from my local LAN arrived tagged with vlan Id 100/200 and the traffic goes through to eth1. But how can I make the packets return to the right eth0.x?
I thought about creating two bridges, one for vlan 100 and one for 200 and connect them to eth1. But again, how do I route the packets received from the internet to arrive to the right bridge?
The current setting:
eth0 <–> br0 <–> eth1
proposed:
1.
eth0.100 <–> br100 <–> eth1
eth0.200 <–> br200 <–> eth1
2.
eth0.100 & eth0.200 <–> br0 <–> eth1
Best Answer
You need to route the traffic from the LAN to WAN.
This is done by a router, not a bridge, so it should look like this :
eth0 (192.168.1.0/24) <==> eth1 (Public Internet)
For the vlans 100 and 200, how to route the traffic to the correct VLAN ? By creating different subnet for each VLAN, so your host knows which vlan is the correct output interface, so it should look like this now :
eth0.100 (192.168.100.0/24) <==> eth1 (Public Internet)
eth0.200 (192.168.200.0/24) <==> eth1 (Public Internet)
Remeber the NAT for both cases:
iptables -I POSTROUTING -t nat -o eth1 -j MASQUERADE