Skip to content

Support smaller MTU when PMTUD is not available (e.g., some VPNs) #299

Open

Description

@joehorsnell

Hi,

I cannot get my mosh session to reconnect over IPsec VPN.

Server:

  • Linux VM (Centos 6.2, kernel 2.6.32-220.13.1.el6.x86_64) in ESX cluster
  • mosh 1.2.2

Client:

  • Mac OS X 10.7.4 (Darwin Kernel Version 11.4.0)
  • mosh 1.2.2

If I start a mosh session to the server over VPN, then disconnect the VPN, I get the blue banner at the top of my session, "mosh: Last contact x seconds ago" but if I reconnect the VPN the session does not reconnect. I just have to quit.

Any ideas? Would you expect this to work over VPN?

Thanks in advance,

Joe.

Activity

  1. keithw commented on Jul 16, 2012

    @keithw
    Member

    Yes, we would expect it to work over VPN (and other users do this regularly).

    Does starting a new mosh session over the VPN work for you?

  2. joehorsnell commented on Jul 16, 2012

    @joehorsnell
    Author

    Yes, I can start a new mosh session (e.g. from my laptop) to the server over the VPN and use it just fine, but if I lose/disconnect the VPN connection, mosh does not reconnect once the VPN connection is reestablished. I can obviously quit the disconnected mosh session and start a new one, but that kind of defeats the object!

    Are there any mosh diagnostics I can gather that might help diagnose what's going on?

  3. keithw commented on Jul 16, 2012

    @keithw
    Member

    Ok, this is a common use case -- the question here is what is changing. Do you contact the server at the same IP address on VPN the first time and the second time?

    You can collect debugging output from the server (start the mosh-server manually as described on http://mosh.mit.edu, using the "-v" argument). One question is whether the server is getting any packets from the client.

    My suspicion is that perhaps the server's IP address is changing over invocations of the VPN.

  4. jamenzin commented on Jul 23, 2012

    @jamenzin

    I'm having the same issue. I contact the server at the same IP address each time. The server has a static IP, and it's not changed in years.

  5. nicowilliams commented on Aug 8, 2012

    @nicowilliams

    It might be nice to have an option by which to say "only attempt to contact server when the outgoing interface is up", then use a PF_ROUTE socket (or, if there's nothing like it, polling) to find out when the interface comes and goes.

  6. ShadSterling commented on Aug 8, 2012

    @ShadSterling

    Is mosh trying to reconnect over the correct outgoing interface?

  7. coty commented on Aug 10, 2012

    @coty

    I'm having this same problem. I just ran mosh-server with -v, connected, disconnected IPSec, and then reconnected IPSec. One thing I found interesting was that while mosh-client wouldn't reconnect, once I quit the client, the server exited, as well.

    FWIW, here is the tail of the -v logging:

    [58242] Received state 23 [ack 4]
    [61179] Sent [4=>23] id 23, frag 0 ack=23, throwaway=4, len=35, frame rate=37.04, timeout=149, srtt=53.1
    [61244] Received state 24 [ack 4]
    [64182] Sent [4=>24] id 24, frag 0 ack=24, throwaway=4, len=26, frame rate=37.04, timeout=149, srtt=53.1
    [64258] Received state 25 [ack 4]
    [67184] Sent [4=>25] id 25, frag 0 ack=25, throwaway=4, len=37, frame rate=37.04, timeout=149, srtt=53.1
    [67246] Received state 26 [ack 4]
    [69550] Received state -1 [ack 4]
    [69551] Sent [4=>26] id 26, frag 0 ack=-1, throwaway=4, len=24, frame rate=37.04, timeout=149, srtt=53.1
    [mosh-server is exiting.]
    
  8. keithw commented on Aug 13, 2012

    @keithw
    Member

    This indicates that the server is receiving datagrams (including the shutdown signal) from the client. But the client isn't receiving anything from the server. This is a little surprising -- can you tcpdump on the client end and see if it sees the packets coming in?

    I also just committed some code that may improve things a bit with some evil NATs. (The client now hops around port numbers if it has not heard from the server in 20 seconds...) So if you want to try upgrading your client and server to the latest Git version, that may be interesting.

  9. eminence commented on Sep 6, 2012

    @eminence
    Member

    For what it's worth -- this is working fine for me, using vpnc-connect to connect to a Cisco VPN (which uses IPSec). That is, I: 1) start up the VPN. 2) mosh to a server on the other side of the VPN. 3) disconnect the VPN (and see the expected blue bar on my mosh session). 4) restart the VPN 5) My mosh session re-connects seamlessly.

    edit: using mosh 1.2.2 on both sides

  10. mjhsieh commented on Sep 7, 2012

    @mjhsieh

    I too have a problem reconnecting mosh after IPSec VPN reconnections with default Mac OS X 10.8 vpnclient. I guess I need to do a tcpdump then.

  11. jc00ke commented on Nov 10, 2014

    @jc00ke

    I'm seeing this behavior too with the Cisco AnyConnect client (3.1.05187) running on Xubuntu. I connect/disconnect from my client's VPN often and I'd love if mosh would keep my connection to my own vps's intact.

  12. AngerM commented on Mar 16, 2016

    @AngerM

    I'm also running into this issue using 1.2.5 w/ OS X client and Centos Server. I'm 99% sure this is an MTU issue. I notice it most often when either reconnecting or when a lot of things on the screen change then I get 'disconnected' from the server, but the server is still receiving all my commands (this can easily be seen using tmux and connecting to the same tmux session via ssh and mosh).

  13. cgull commented on Jul 12, 2016

    @cgull
    Member

    There are clearly some problems with Mosh and VPN and public networks, as we see here, on #773, and IRC. But reports of "It doesn't work for me" aren't enough for us to be able to clearly determine what's going on.

    If you run into problems with VPN, it will help us greatly if you can:

    • give us a packet capture of a session that hangs, preferably at both client and server
    • figure out what the path MTU is from your server to your client, manually with ping or more automatically with tracepath or similar
    • name the public network and the VPN software you're using

    I know these aren't always easy asks, technically or politically, but they will help us better establish what's going on with VPNs. Thanks!

  14. jtlawson commented on Jan 24, 2017

    @jtlawson

    At the university where I work, we have a Cisco VPN product. When connected to the VPN, my MTU is 1100 bytes. (ping -s 1072 to the mosh server works, ping -s 1073 and above doesn't.) I experience the same behaviors described by others.

    I was running mosh 1.2.6 on both client (OS X 10.11.6, mosh from macports) and server (RHEL 6, RPM built from source.)

    I patched in PR #836 on the server but it did not seem to make a difference in behavior.

    Then I modified src/network/network.h and dropped DEFAULT_IPV4_MTU to 1072, rebuilt the server, and since that time I haven't had troubles when connected to the VPN.

    This should work for me until mosh performs some sort of ICMP-less PMTUD.

  15. cgull commented on Jan 27, 2017

    @cgull
    Member

    Thanks for that report.
    In your case, since you're actually associated with the organization providing you that VPN, you might be able to do something. Mosh traffic should still be getting through as fragmented IP packets. Possibly your university has a poorly configured VPN that drops fragmented packets? If so, raise the issue with them, it shouldn't be doing that.
    Alternately, perhaps your server is sending packets with the dont-fragment bit set somehow, which would be a problem. What OS is your server? Can you run tcpdump there and check for the DF bit?

  16. 1 remaining item

  17. Khalian commented on Jul 5, 2019

    @Khalian

    Yes setting a lower MTU value worked for me. My VPN is enterprise grade Cisco.

    Are there any misgivings to reducing the MTU value to 1072 in code. I can submit a PR with that change (unless someone can think of other issues it can cause).

  18. jtlawson commented on Jul 8, 2019

    @jtlawson

    Hi Khalian,

    For what it's worth, my institution was able to adjust the Cisco VPN configuration to allow for a larger MTU, so changing DEFAULT_IPV4_MTU is no longer necessary for me. You might ask the folks who run your enterprise grade Cisco to look into this.

  19. Khalian commented on Jul 8, 2019

    @Khalian

    [comment redacted by Mosh maintainers -- your contributions are welcome, but assailing other participants in the discussion is not necessary]

  20. keithw commented on Jul 9, 2019

    @keithw
    Member

    I think as a long-term fix, we probably do want Mosh to stop relying on ICMP to perform Path MTU discovery (i.e. we want PLPMTUD instead of just PMTUD). There is a nice and pretty-well-specified algorithm for this if somebody wants to implement it (https://tools.ietf.org/html/rfc4821).

    The Cisco VPN is broken if its behavior is correctly described here (it MUST fragment a non-DF datagram -- it can't just drop it, per RFC 1812), but this seems to be a fact of life and we won't get far shouting into the wind. And anyway, we don't want Mosh's datagrams to get fragmented anyway.

    Just lowering the default MTU in Mosh seems like kind of a lame way to deal with this, but maybe if Cisco is the worst offender this will fix a reasonable subset of the users. What is the biggest datagram that the Cisco VPNs will let through in their default configuration? I guess I would be willing to do this if we couple it with a bug report to Cisco.

  21. Khalian commented on Jul 9, 2019

    @Khalian

    @keithw Thank you for bringing this discussion in a more productive direction.

    So I ran a few commands to test it :

    networksetup -getMTU en0
    Active MTU: 1500 (Current Setting: 1500)

    This is a mac's upper bound on the MTU.

    However that does not actually seem to work when I am connected over my cisco VPN (note this is using default settings).

    ping -D -s 1500 www.google.com
    PING www.google.com (172.217.7.196): 1500 data bytes
    ping: sendto: Message too long

    Thats also the case for the value set at mosh's MTU

    ping -D -s 1280 www.google.com
    PING www.google.com (172.217.7.196): 1280 data bytes
    ping: sendto: Message too long
    ping: sendto: Message too long

    For me the exact thresh hold is

    ping -D -s 1222 www.google.com
    PING www.google.com (172.217.7.228): 1222 data bytes
    76 bytes from 172.217.7.228: icmp_seq=0 ttl=45 time=60.224 ms

    When going off the VPN it works fine upto the upper bound.

    I cant convincingly say that my org put the MTU value to that, but the VPN does not seem to be able to send the traffic over that value and is clearly not fragmenting the packets according to the RFC you specified.

    So that leads me to conclude that this indeed is a cisco bug. That being said I am not sure that essentially making this a cisco only thing is feasible, since this is a wide spread impact.

    Whats the misgivings over reducing the MTU value right now to alleviate pain? Is the expected number of data grams going to increase making mosh untenable for certain use cases?

  22. keithw commented on Jul 9, 2019

    @keithw
    Member

    Huh, I'm confused -- if ping is getting an error message, does mosh-client also get that error? Because we do actually have code to respond to that error by setting the MTU to 500.

    mosh/src/network/network.cc

    Lines 412 to 414 in fecd4ee

    if ( errno == EMSGSIZE ) {
    MTU = DEFAULT_SEND_MTU; /* payload MTU of last resort */
    }

    But maybe the mosh-client is doing the right thing but it's the mosh-server that never learns its packets are getting dropped? What happens to an incoming UDP datagram that's too big -- the Cisco VPN is really supposed to fragment it, not just silently drop it. (Or I guess in some crazy world, send an ICMP too-big back to the source, but that wouldn't be right either if DF is not set.)

    If you really want to set the Mosh IPv4 MTU down to 1200 for now, I'm fine with it, but I would want it to be coupled with a bug report to Cisco and to make sure we understand how their VPN behaves (e.g. upstream vs. downstream traffic, etc.).

  23. Khalian commented on Jul 9, 2019

    @Khalian

    "Huh, I'm confused -- if ping is getting an error message, does mosh-client also get that error? Because we do actually have code to respond to that error by setting the MTU to 500."

    Should it not? I thought that MTU is defined at the IP layer and should be agnostic layer 4 up? Or is ICMP special?

    "If you really want to set the Mosh IPv4 MTU down to 1200 for now, I'm fine with it, but I would want it to be coupled with a bug report to Cisco and to make sure we understand how their VPN behaves (e.g. upstream vs. downstream traffic, etc.)."

    I can submit the report, but cisco bug reports are tied down to specific accounts. Is there a community account that might be more appropriate?

    Yes I can put it to 1200 but other people have complained about 1072 being their thresh hold. I have been scrounging for documentation for a while but I cant find a central config. For all I know could be more than one offering by cisco and they have different values.

  24. dm1090 commented on Sep 30, 2020

    @dm1090

    I still see this issue more than 8 years after originally reported. Any plans to fix it?

    Client: Ubuntu 16.04 running on Parallels VM on Mac OS X 10.14.6
    Server: Ubuntu 16.04

    MTU selection should be part of a handshake between mosh client and server every time they reconnect.

  25. SuperBo commented on Feb 24, 2021

    @SuperBo

    Bump, VPN connection is very popular and I can’t use Mosh due to this error :(

  26. achernya commented on Jan 19, 2023

    @achernya
    Collaborator

    I think we should add a --mtu argument to mosh to allow users to override the default MTU.

  27. added this to the mosh-1.5.0 milestone on Jan 19, 2023
  28. changed the title [-]mosh does not reconnect over IPsec VPN[/-] [+]Support smaller MTU when PMTUD is not available (e.g., some VPNs)[/+] on Jan 19, 2023
  29. added a commit that references this issue on Oct 22, 2026
    a4b9d48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions