WAN port on router acts as LAN

Here is the output

###########################################################
###############   ip route show | grep " src " | cut -d " " -f 3,1  ####
######################################################################

10.64.64.64 3g-wan6
192.168.4.0/24 br-lan

Here is the output when I connected my computer to the internet source using an ethernet cable. From the enp0s25 interface you can see it is acquiring IP via DHCP.

##################################################
################ ifconfig #####################
#################################################

enp0s25   Link encap:Ethernet  HWaddr a4:5d:36:58:8e:e4  
          inet addr:192.168.0.132  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::d7a2:fabf:f429:d7c4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2488 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1329 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3410036 (3.4 MB)  TX bytes:117027 (117.0 KB)
          Interrupt:17 Memory:d4700000-d4720000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8097 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8097 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:604442 (604.4 KB)  TX bytes:604442 (604.4 KB)

wlo1      Link encap:Ethernet  HWaddr 6c:88:14:bd:b8:64  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:255897 errors:0 dropped:0 overruns:0 frame:0
          TX packets:138170 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:337800157 (337.8 MB)  TX bytes:12232973 (12.2 MB)

The problem is here:

config interface 'wan6'
	option ifname 'eth0.2'
	option proto '3g'
	option device '/dev/ttyUSB2'
	option ipv6 'auto'

You are using the eth0.2 ifname on an interface which is used for 3G with a USB stick.

Change them into this:

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

config interface '3g'
	option proto '3g'
	option device '/dev/ttyUSB2'
	option ipv6 'auto'

and add new interface 3g in wan firewall zone.
I would also advise to reset the router to defaults, after you take a backup. wan and lan will work immediately and you'll only need to apply the configuration for 3G. This way you'll make sure that no other wrong configuration is still in the router.

2 Likes

Changes have been done but it still has the same old behaviour. See output below. This is really strange

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 'fd4a:226f:5b58::/48'

config interface 'lan'
	option type 'bridge'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.4.4'
	option ifname 'eth0.1'

config device 'lan_dev'
	option name 'eth0.1'

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

config device 'wan_dev'
	option name 'eth0.2'

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

config interface '3g'
	option proto '3g'
	option device '/dev/ttyUSB2'
	option ipv6 'auto'

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

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '1 2 3 4 6t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '0 6t'

Then proceed with backup, reset, and reconfigure.

After the reset the router will work without any additional setting. The lan will have 192.168.1.1/24 and wan will acquire some IP from the 192.168.0.0/24 subnet.
After you make sure it works, you can add the configuration for the 3g.

1 Like

So we backedup, reset and configured and still it behaves the same way.

We noticed that if you switch WAN ifname to eth0.1 and LAN ifname to eth0.2, the WAN starts working but the LAN stops and if you switch it back, the LAN starts working and WAN stops.

This is a strange behaviour.

Connect the WAN and check the runtime switch and bridge configuration:

swconfig dev switch0 show; brctl show

Analyze which links are UP and compare with your port number assignment.

1 Like

Before reconfiguring, you should try it and verify it works. DHCP client on wan interface works out of the box.

1 Like

Once you connect WAN, you will be unable to SSH into the router because the router now receives IP of the WAN connection.

1 Like

You can temporarily allow SSH from the WAN interface.
In addition, you can create an alias interface that will have a private static IP different from your LAN and WAN subnets.

1 Like

I created an Alias interface with an IP address of 10.0.0.1. when I connect an internet source to the WAN port of the router, it stops working ( i.e I will not be able to ssh into the Alias interface I created) but once I disconnect the internet source from the WAB port of the router, it starts working ( i.e I will be able to ssh into the Alias interface)

Check the logs after you plug/unplug the internet cable in the wan port.
logread
Which port came up?

2 Likes

I have added the logread from both scenarios to a gist. The output is too large to paste here.

I named the files according to each scenario.

Thanks

In the logs I can see port 4 going up/down.
Fri Sep 25 15:03:36 2020 kern.info kernel: [ 730.547827] mtk_soc_eth 10100000.ethernet eth0: port 4 link down
This port however belongs to lan.

So my question is: are you plugging the cable to the right port?

2 Likes

We are plugging this correctly. Like I mentioned earlier in this thread here
There seems to be an issue with the interface names.

I can schedule a call at your convenient time to show you a live video

Then there is something wrong with the mapping of the ports and you need to identify yourself which one is the wan port.
Open Network/Switch in Luci web page and you'll see there the port that is connected to your PC. Connect some other pc to the remaining ports and see on the top which port is marked as connected. Do that until the wan port (the one which is marked as untagged on vlan2) shows as connected.

2 Likes

I have done this.
The port mapping is correct. All ports were coming up according to the numbers correctly. The WAN port came up as port 5.

I noticed that there is a message in red that appeared on the top of Network/Switch in Luci web page the reads

Switch switch0 has an unknown topology - the VLAN settings might not be accurate

Is this normal?

According to the mapping, port 0 is on vlan 2, which is the wan interface.

This could explain the problem you are facing.

1 Like

Is there a way to remap it?

Not that I know of. Just find which port on the router is physical port 0 and use that one for wan.

2 Likes