OpenWrt Forum Archive

Topic: Converting the switch to 4 separate Ethernet ports - Success

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I wanted to convert the 4 port switch in my wrt54g v2 in to 2 separate vlans, port 1 to connect to my private lan and will have address 192.168.1.1, port 2 3 and 4, as my dmz network which will have servers in public ip addresses assigned from my ISP and wan interface the internet connection. I was following the discussion in  http://openwrt.org/forum/viewtopic.php?t=6 and another url to sveasoft forums posted in that discussion at http://www.sveasoft.com/modules/phpBB2/ … .php?t=191.

The sveasoft forum has a nifty instruction to get multiple vlans working, by using vlan*ports and vlan*hwname in nvram. So I checked it out and now mine is working perfectly.

My nvram settigns are:

root@wrt:/# nvram show | grep vlan
size: 1666 bytes (31102 left)
vlan0hwname=et0
vlan0ports=1 5*
vlan1hwname=et0
vlan1ports=0 5
vlan2hwname=et0
vlan2ports=2 3 4 5
wan_ifname=vlan1

and ifconfig output:

br0       Link encap:Ethernet  HWaddr 00:0F:66:BF:CD:EE  
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:971 errors:0 dropped:0 overruns:0 frame:0
          TX packets:876 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:74434 (72.6 KiB)  TX bytes:448360 (437.8 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0F:66:BF:CD:EE  
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:15862 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1704 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:1534237 (1.4 MiB)  TX bytes:536173 (523.6 KiB)
          Interrupt:5 Base address:0x2000 

eth1      Link encap:Ethernet  HWaddr 00:0F:66:BF:CD:F0  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:12 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:4 Base address:0x1000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

vlan0     Link encap:Ethernet  HWaddr 00:0F:66:BF:CD:EE  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:972 errors:0 dropped:0 overruns:0 frame:0
          TX packets:876 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:80454 (78.5 KiB)  TX bytes:451864 (441.2 KiB)

vlan1     Link encap:Ethernet  HWaddr 00:0F:66:BF:CD:EE  
          inet addr:111.111.11.232  Bcast:255.255.255.255  Mask:255.255.248.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14854 errors:0 dropped:0 overruns:0 frame:0
          TX packets:816 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1166467 (1.1 MiB)  TX bytes:83141 (81.1 KiB)

vlan2     Link encap:Ethernet  HWaddr 00:0F:66:BF:CD:EE  
          inet addr:192.168.2.1  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:45 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:6168 (6.0 KiB)

One important precaution is that you need to take is to always enclose multiple numbers in double quotes, while setting the values. for example:

nvram set vlan2ports="2 3 4 5"

If you did not do this, you may have to reset the wrt (by pressing reset button for 5 seconds while poweron) and connect it from 192.168.1.x network to bring it back again.

Now I am looking for a way to set the vlan2 interface address permanently.

raj

Good stuff!  smile

All you need to do to set the network address for vlan2 is to add the line 'ifconfig vlan2 inet 192.168.2.1 netmask 255.255.255.0' to the startup scripts somewhere. At the bottom of /etc/init.d/S40network is as good a place as any.

After one day with this setup, I found a serious flaw with this. I loose my connectivity to the box if I restart the network in my work machine. My work machine (a hd installed knoppix box) is connected to port1 of wrt. wrt is in turn connected to internet and nats for my work machine.

After I restart my network, I loose all network connectivity to wrt, my telnet session freezes, pings are not answered. Any working pings suddenly stops. The connectivity is restored once I restart wrt.

Another observation is that, My machine is not able to get it's ip using dhcp if this modification is enabled.

So now I have stopped using it and appended this script to /etc/init.d/S40network to get the same settings.

admcfg port1 PVID:0 vlan0
admcfg port0 PVID:1 vlan1
admcfg port2 PVID:2 vlan2
admcfg port3 PVID:2 vlan2
admcfg port4 PVID:2 vlan2
vconfig add eth0 2
vconfig add eth0 3         
vconfig add eth0 4
ifconfig vlan2 172.16.1.1 netmask 255.255.255.0

But I still wonder what is the reason for the strange behaviour in the first place!

raj

The discussion might have continued from here.