OpenWrt Forum Archive

Topic: lan and wan on one ethernet port with vlan

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

Hi,

i'm new here and i have a problem.

I have a fonera wlan router with openwrt kamikaze 8.09.2 on it, which only has one ethernet port.
The configuration at the moment is that i connect to the router over wlan and the single ethernet port is the wan port, which connects over pppoe to the internet.

I wanted to know if it is possible to configure the ethernet port with vlan's so that i can connect a switch to the port. And in the switch i plug in the cable from the modem and other machines. I want to connect to the lan network of the router over wlan and over cable (through the switch) and also want that the router connects to the internet over the switch.
I'm not so firm in vlan's and routing, so i hope that someone here can help me or point me to a solution of my problem.

Greetz,
drooler

You will need a managed switch for this scenario. For the cost of that you could buy a new openwrt router which normally has a built-in switch (managed too) as well. It just depends how many ports you need and what speed, GBit or not.

(Last edited by MMCM on 12 May 2010, 09:00)

Is there any other way to do this without vlan's, so that i can connect to the internet and to the lan through the single ethernet port?

Fonera might not support vlan switch section in the network configuration. If binding pppoe to br-lan, the /usr/sbin/pppd won't start. Please replace ppp-mod-pppoe with rp-pppoe-client and modify /etc/ppp/pppoe.conf, /etc/ppp/pap-secrets and /etc/ppp/chap-secrets accordingly. Set "ETH=br-lan" in /etc/ppp/pppoe.conf and execute "/etc/init.d/pppoe-client start" and there you have pppoe and lan on the same ethernet port. You have to modify firewall rules by yourself. I don't know if X-Wrt Webif2 can take care of it.

Edit:
The behavior difference between ppp-mod-pppoe and rp-pppoe-client is that ppp-mod-pppoe will remove the wan interface from bridge and reset the ip address while rp-pppoe-client simply binds the new ip address to ppp0.

ppp-mod-pppoe

Aug 22 04:06:39 OpenWrt daemon.info pppd[1726]: Plugin rp-pppoe.so loaded.
Aug 22 04:06:40 OpenWrt daemon.notice pppd[1726]: pppd 2.4.4 started by root, uid 0
Aug 22 04:06:40 OpenWrt daemon.info pppd[1726]: PPP session is 6783
Aug 22 04:06:40 OpenWrt daemon.info pppd[1726]: Renamed ppp0 to pppoe-wan
Aug 22 04:06:40 OpenWrt daemon.info pppd[1726]: Using interface pppoe-wan
Aug 22 04:06:40 OpenWrt daemon.notice pppd[1726]: Connect: pppoe-wan <--> br-lan
Aug 22 04:06:40 OpenWrt daemon.notice pppd[1726]: PAP authentication succeeded

rp-pppoe-client

Aug 22 04:03:56 OpenWrt daemon.notice pppd[1662]: pppd 2.4.4 started by root, uid 0
Aug 22 04:03:56 OpenWrt daemon.info pppd[1662]: Using interface ppp0
Aug 22 04:03:16 OpenWrt daemon.notice pppd[1627]: Connect: ppp0 <--> /dev/pts/0
Aug 22 04:03:56 OpenWrt daemon.debug pppoe[1667]: PADS: Service-Name: ''
Aug 22 04:03:56 OpenWrt daemon.info pppoe[1667]: PPP session is 6482 (0x1952)
Aug 22 04:03:57 OpenWrt daemon.warn pppd[1662]: Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Aug 22 04:03:57 OpenWrt daemon.warn pppd[1662]: Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Aug 22 04:03:58 OpenWrt daemon.notice pppd[1662]: PAP authentication succeeded

(Last edited by fyi on 21 Aug 2010, 22:04)

Just got it worked by ppp-mod-pppoe. Since ppp-mod-pppoe removes the ip address of the interface so just add it back.

/etc/config/network:

config 'interface' 'loopback'
    option 'ifname' 'lo'
    option 'proto' 'static'
    option 'ipaddr' '127.0.0.1'
    option 'netmask' '255.0.0.0'

config 'interface' 'lan'
    option 'type' 'bridge'
    option 'ifname' 'eth0'    #'eth0.1 eth0.2' for La Fonera+
    option 'proto' 'static'
    option 'netmask' '255.255.255.0'
    option 'ipaddr' '192.168.1.1'

config 'interface' 'wan'
    option 'ifname' 'br-lan'
    option 'proto' 'pppoe'
    option 'username' 'USERNAME@YOURDOMAIN.COM'
    option 'password' 'PASSWORD'
    option 'keepalive' '3'
    option 'ppp_redial' 'persist'
    option 'persist'

#In case you brick your router
config 'alias'
    option 'interface' 'wan'
    option 'proto' 'static'
    option 'ipaddr' '169.254.255.1'
    option 'netmask' '255.255.0.0'

Create /etc/init.d/custom-user-startup:

#!/bin/sh /etc/rc.common
START=98
start() {
    ifup wan
    ifconfig br-lan 192.168.1.1 netmask 255.255.255.0
}

Manually execute:

chmod +x /etc/init.d/custom-user-startup
/etc/init.d/custom-user-startup enable

The above instructions will generate /etc/rc.d/S98custom-user-startup.

Reboot and check the result:

root@OpenWrt:/# route ; brctl show
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
xxx.xx.xx.xxx   *               255.255.255.255 UH    0      0        0 pppoe-wan
192.168.1.0     *               255.255.255.0   U     0      0        0 br-lan
169.254.0.0     *               255.255.0.0     U     0      0        0 br-lan
default         *               0.0.0.0         U     0      0        0 pppoe-wan
bridge name     bridge id               STP enabled     interfaces
br-lan          8000.001884aabbcc       no              ath0
                                                        eth0

(Last edited by fyi on 23 Aug 2010, 09:38)

I don't have La Fonera so I use ASUS WL-HDD2.5 as the test bed.

/etc/config/network:

config 'switch' 'eth0'
    option 'vlan0' '1 2 3 4 5*'
    option 'vlan1' '0 5'

config 'interface' 'loopback'
    option 'ifname' 'lo'
    option 'proto' 'static'
    option 'ipaddr' '127.0.0.1'
    option 'netmask' '255.0.0.0'

config 'interface' 'lan'
    option 'type' 'bridge'
    option 'ifname' 'eth1'
    option 'proto' 'static'
    option 'ipaddr' '192.168.1.1'
    option 'netmask' '255.255.255.0'

config 'interface' 'wan'
    option 'ifname' 'br-lan'
    option 'proto' 'pppoe'
    option 'username' 'USERNAME@YOURDOMAIN.COM'
    option 'password' 'PASSWORD'
    option 'keepalive' '3'
    option 'defaultroute' '1'
    option 'ppp_redial' 'persist'
    option 'persist'

#In case you brick your router
config 'alias'
    option 'interface' 'wan'
    option 'proto' 'static'
    option 'ipaddr' '169.254.255.1'
    option 'netmask' '255.255.0.0'

/etc/init.d/custom-user-startup:

#!/bin/sh /etc/rc.common
START=98
start() {
    ifup wan
    wifi up
    ifconfig br-lan 192.168.1.1 netmask 255.255.255.0
}

Manually execute:

chmod +x /etc/init.d/custom-user-startup
/etc/init.d/custom-user-startup enable

The above instructions will generate /etc/rc.d/S98custom-user-startup.

Reboot and check the result:

root@OpenWrt:~# route ; brctl show
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
xxx.xx.xx.xxx   *               255.255.255.255 UH    0      0        0 ppp0
192.168.1.0     *               255.255.255.0   U     0      0        0 br-lan
169.254.0.0     *               255.255.0.0     U     0      0        0 br-lan
default         xxx.xxx.xxx.xxx 0.0.0.0         UG    0      0        0 ppp0
bridge name     bridge id               STP enabled     interfaces
br-lan          8000.0015f2aabbcc       no              eth1
                                                        wl0

The discussion might have continued from here.