Reconfigure lan port as wan

hi,

I have a ADSL router (netgear dgn3500) and would like to use it without ADSL connection.
Is it possible to configure one of the existing lan interfaces to act as wan?

EDIT: sorry, it is my bad google day. Found the answer.

--pawel

Sure.
You have to assign one of the ethernet port to another VLAN (untagged), before you must remove this port to the default VLAN (usually it is 1). Then in the CPU port, add the same VLAN as tagged. A new interface will be created, suppose the CPU interface is eth0 and you choosed VLAN 2 for the trick, it will be eth0.2. Then create a WAN interface using eth0.2 and set the firewall rules according.

This is my /etc/config/network which configures port 1 into wan.

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

config globals 'globals'
    option ula_prefix 'fda3:e740:53e7::/48'
 
config interface 'lan'
    option type 'bridge'
    option ifname 'eth0.1'
    option proto 'static'
    option ipaddr '192.168.1.1'
    option netmask '255.255.255.0'
    option ip6assign '60'

config device 'lan_dev'
    option name 'eth0.1'
    option macaddr '00:26:F2:52:48:F0'

config interface 'wan'
    option ifname 'eth0.2'
    option proto 'dhcp'

config device 'wan_dev'
    option name 'eth0.2'
    option macaddr '00:26:F2:52:48:F1'

config interface 'wan6'
    option ifname 'eth0.2'
    option proto 'dhcpv6'

config switch
    option name 'switch0'
    option enable_vlan '1'

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

config switch_vlan
    option device 'switch0'
    option vlan '2'
    option ports '3 5t'
2 Likes

Kudos for coming back and posting the answer!

I have a follow up question.
When the router is rebooted, switch resets its configuration. If at the same time there is a lan dhcp client trying to get ip, this request will end up on the wan side, not yet configured to be wan. So the client will end up with wan assigned ip.
I have observed it once and I am not sure if this is a common feature or was just me doing something totally wrong.
Assuming, I did not misdiagnose, is there any simple way to prevent it?
Actually I can try to reproduce by power cycling the router. Need a moment alone at home, otherwise there are complains :slight_smile:

I think I've seen a similar issue pop-up on the forum in the past, I don't believe there was a reliable solution proposed. Try pinging experts either here or on IRC.

does the switch get reconfigured properly later?

I've done some pretty "interesting" thinks with using lan ports on many
different networks and have never had a problem with things coming up on the
wrong network. I make sure the switch is configured in /etc/config/networks and
it has all "just worked", or at least, I've never run into a timing issue.

David Lang
k

Here is a bit more information on how I did it https://gist.github.com/tiagonmas/48ec43ba281c220e544ca55eea9384cd