Unable to set MTU as 1492 from 1500

Hello folks,

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'

ifconfig and ip link outuput:

eth0      Link encap:Ethernet  HWaddr XXXX
          inet addr:192.168.150.10  Bcast:192.168.150.255  Mask:255.255.255.0
          inet6 addr: fe80::c38:f0ff:fexxxx/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3170514 errors:0 dropped:300 overruns:0 frame:0
          TX packets:4636334 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:234404316 (223.5 MiB)  TX bytes:6032258296 (5.6 GiB)
          Interrupt:29

eth1      Link encap:Ethernet  HWaddr 0E:38:14:8C:4C:6D
          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::c38:14ff:fexxxx/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1492  Metric:1
          RX packets:4650307 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3171269 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5968626587 (5.5 GiB)  TX bytes:230726730 (220.0 MiB)
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

Can someone help me?

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.

Luci MTU option it's broken iirc

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.

You have 1492 configured on your wan interface. Just remove that line and reload config or reboot.

I think that MTU option doesn't work on nanopi. I had similar problem in my parents house with one, but i can't confirm if that happens right now.

Maybe it's a problem in snapshots and not from nanopi's build... I don't know.

EDIT: I tried it right now and changing MTU in wan works without problems in latest snapshot.

If I do that it will use the default 1500 MTU but I want to set it to 1492

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.

This is all wrong. Leave the mtu to the default 1500, unless the ISP router has a different setting for mtu on its lan interface.

Nanopi R2S. Download new snapshots and try it.

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.

3 Likes

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.

MTU

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.
image

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.

Because the problem isn't the MTU.

3 Likes

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.

  1. Where did you see that exactly?
  2. Which link is suspicious for that?
  3. Run an extended ping to verify #2 ping -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.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.