I have a NanoPi R2S that runs the version 19.07.01 kernel 5.4.61 that sits between my ISP router and a switch. The setup is 2 interfaces, one wan e one lan, with statics addresses. I have a working internet connection, but some packets are dropped and a think that the reason is the incorrect MTU setting. My link runs over PPPoE in the ISP router that I'm unable to config a bridge mode unfortunately. There are my configs:
config interface 'lan'
option ifname 'eth1'
option proto 'static'
option netmask '255.255.255.0'
option ipaddr '192.168.0.1'
option mtu '1492'
config interface 'wan'
option ifname 'eth0'
option proto 'static'
option netmask '255.255.255.0'
option ipaddr '192.168.150.10'
list dns '1.1.1.1'
list dns '1.0.0.1'
list dns '9.9.9.9'
option mtu '1492'
option gateway '192.168.150.1'
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether XXXX brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc pfifo_fast state UP qlen 1000
link/ether XXXX brd ff:ff:ff:ff:ff:ff
4: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether XXXX brd ff:ff:ff:ff:ff:ff
5: ifb0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 32
link/ether XXXX brd ff:ff:ff:ff:ff:ff
6: ifb1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 32
link/ether XXXX brd ff:ff:ff:ff:ff:ff
7: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN qlen 1000
link/gre 0.0.0.0 brd 0.0.0.0
8: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
9: erspan0@NONE: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
The eth0 is the interface that I want to change the MTU, but when I try to change it via ifconfig or via ip commands i get the following error: SIOCSIFMTU: Invalid argument
I think that the MTU is causing the packet loss because from my tests with ping. Packet with size between 1493 and 1500 inclusive are silently dropped.
I've tried with uci as well and no success. Then I connected my PC directly in the ISP router and it works as I expected. Packets above 1492 bytes are answered with a ICMP packet that tells the computer that the size is too big. Even if I cant set the interface MTU to 1492 in OpenWrt, a workaround that tells the client about the correct MTU should be enough to prevent the packet loss.
Are you using the same R2S or it is another board? I'm starting to think that this is a driver issue. And where do you get these snapshots? I've got mine from the downloads page in the wiki and they are dated as 09/04/20.
Hello, so if there is another router we should set MTU to 1500 because it gonna fragment every packet to fit in 1492, right? Wouldnt be better to set MTU to 1492 in openwrt WAN too so the ISP router dont have to fragment them?
The mtu must match within the same segment. It makes things worse to change the openwrt router wan interface mtu to 1492 if the lan of the ISP router is 1500, which is the default in ethernet.
I've already tried to don't manually set the MTU, witch make it 1500 and results in packet loss. My internet link runs over PPPoE so I need to set the MTU to 1492 to account the protocol overhead.
Thanks for the suggestion. I've download the snapshot of the board and tested, but got the same error message. This looks like a kernel driver related issue after some research in the web. I will try Armbian and Ubuntu Core just to be sure.
It works for me. I've got an MTU of 1500, but if i set it to 1492 and try to ping with a packet higher than 1492 it will get fragmented.
Don't use luci to set MTU because it will breaks your network config. Your wan config should look like this.
config interface 'wan'
option ifname 'eth0'
option proto 'static'
option netmask '255.255.255.0'
option ipaddr '192.168.150.10'
list dns '1.1.1.1'
list dns '1.0.0.1'
list dns '9.9.9.9'
option mtu '1492'
option gateway '192.168.150.1'
config device 'wan_eth0_dev'
option name 'eth0'
option macaddr 'xx:xx:xx:xx:xx'
I've tried this workaround with the manufacturer image and it doesn't worked, it created a virtual interface with the correct MTU but the packet loss persisted. I will try with the snapshot image, maybe it works.
Let's take one step back because we have an XY problem here. @garmendes, first roll back mtu to 1500. Also you said that you experience packet loss.
Where did you see that exactly?
Which link is suspicious for that?
Run an extended ping to verify #2ping -c 10000 -f -s 1472 -M do IP_OF_A_HOST
Where the IP_OF_A_HOST can be some host on the lan interface or the upstream router on the wan interface.
I was able to solve the problem with your help, thank you guys. I started from the beginning and flashed again the image on the card. Then configured everything and all things worked with no packet loss. But as soon as I connected the switch I started to loose packets. I ran a tcpdump on the NanoPi and observed that the packets above 1492 bytes never arrived, so they are discarded by the switch. The thing was a hidden MTU pref that only show if in some conditions in the switch, and after a reset to default settings everything worked as expected.