OpenWrt Forum Archive

Topic: Share Internet from LAN to wireless interface

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

Hi. I'm trying to setup a network with my main router and a OpenWRT one.

The OpenWRT device is connected to the main router with a Ethernet cable, and has an access point with a different network IP.

The problem is I cannot configure it to get Internet from the main router and distribute it to the clients connected to the AP.

http://i.imgur.com/n9LlG.png

Thanks in advance.

(Last edited by fragaycia on 24 Dec 2012, 12:21)

Upcoming questions:

1) Do you like to have the main router and the OpenWrt subnet to be on different subnets?

2) Is your main router the gateway, DNS and DHCP server for your complete LAN?

(Last edited by written_direcon on 24 Dec 2012, 12:55)

written_direcon wrote:

Upcoming questions:
1) Do you like to have the main router and the OpenWrt subnet to be on different subnets?
2) Is your main router the gateway, DNS and DHCP server for your complete LAN?

1. Exactly, that's what I want.
2. Yeah.

By the way, I forgot to mention. The LAN interface in the OpenWRT has the IP 192.168.0.100, and the DHCP server is disabled in that interface.

Thank you.

(Last edited by fragaycia on 24 Dec 2012, 13:00)

Okay then you should:

1) Enable the DHCP server on the OpenWrt router again. It's for the LAN & WiFi by default.

2) Connect the OpenWrt's WAN port to one of the main routers LAN port.

3) The clients connecting to the OpenWrt router should be in DHCP client mode

That should do it. But remember you are doing double NAT then (on the main and OpenWrt router), which isn't a optimal solution.

(Last edited by written_direcon on 24 Dec 2012, 13:09)

written_direcon wrote:

Okay then you should:

1) Enable the DHCP server on the OpenWrt router again. It's for the LAN & WiFi by default.

2) Connect the OpenWrt's WAN port to one of the main routers LAN port.

3) The clients connecting to the OpenWrt router should be in DHCP client mode

That should do it. But remember you are doing double NAT then (on the main and OpenWrt router), which isn't a optimal solution.

The problem here is I don't know which one's the WAN port in the OpenWRT. That's the only problem, the DHCP server in OpenWRT is working and giving addresses.

The router I'm using is this one:
http://wiki.openwrt.org/toh/huawei/hg553

Then login to your OpenWrt and do trial & error to find out which port is the WAN port. You can do this by switching the ethernet cable between the ports and by runnung the 'ifdown wan && ifup wan' command.

The WAN interface should get an IP address from the main routers subnet. Check with 'ifconfig' command.

Another question: Which OpenWrt router do you own?

(Last edited by written_direcon on 24 Dec 2012, 13:21)

There you go (Switch Ports (for VLANs)):

Switch port #4 = WAN

(Last edited by written_direcon on 24 Dec 2012, 13:23)

Switch Ports (for VLANs)
Numbers 0-3 are Ports 1-4 as labeled on the unit, number 4 is the Internet (WAN) on the unit, 5 is the internal connection to the router itself. Don't be fooled: Port 1 on the unit is number 3 when configuring VLANs. vlan0 = eth0.0, vlan1 = eth0.1 and so on.

There's no connection for the number 4 (WAN), only the labeled one.
Also, if I change the cable between the ports, it always shows it's the WAN connection in the status page:

http://i.imgur.com/wBobX.png

Sorry if it seems I'm a noob, is just English is not my first language and sometimes it's hard to explain these things haha

Hi again! After a long time, I tried this again, and I was able to make the switch work with this config:

config interface 'lan'
        option proto 'static'
        option ipaddr '192.168.0.69'
        option netmask '255.255.255.0'
        option gateway '192.168.0.1'
        option dns '8.8.8.8'
        option nat '1'
        option ifname 'eth1.0'

config interface 'wan'
        option ifname 'eth1.1'
        option proto 'dhcp'

config switch 'eth1'
        option enable '1'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'eth1'
        option vlan '0'
        option ports '0 1 2 5t'

config switch_vlan
        option device 'eth1'
        option vlan '1'
        option ports '3 5t'

config interface 'wifi'
        option proto 'static'
        option ipaddr '192.168.2.1'
        option netmask '255.255.255.0'
        option nat '1'

Now the problem is, by default, it takes the "lan" interface as WAN. If I stop that interface, then it takes the correct one (Port #4), getting IP from DHCP.

But, after connecting a client to the wifi interface, it doesn't get Internet. I'm not sure if I have to set a bridge between the interfaces so... any help about this?

Thank you again!

The discussion might have continued from here.