You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support smaller MTU when PMTUD is not available (e.g., some VPNs) #299
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?
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?
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?
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.
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.]
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.
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.
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.
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).
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!
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.
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?
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).
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.
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.
@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?
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.
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.).
"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.
Activity
keithw commentedon Jul 16, 2012
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?
joehorsnell commentedon Jul 16, 2012
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?
keithw commentedon Jul 16, 2012
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.
jamenzin commentedon Jul 23, 2012
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.
nicowilliams commentedon Aug 8, 2012
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.
ShadSterling commentedon Aug 8, 2012
Is mosh trying to reconnect over the correct outgoing interface?
coty commentedon Aug 10, 2012
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:
keithw commentedon Aug 13, 2012
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.
eminence commentedon Sep 6, 2012
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
mjhsieh commentedon Sep 7, 2012
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.
jc00ke commentedon Nov 10, 2014
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
moshwould keep my connection to my own vps's intact.AngerM commentedon Mar 16, 2016
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).
cgull commentedon Jul 12, 2016
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:
pingor more automatically withtracepathor similarI know these aren't always easy asks, technically or politically, but they will help us better establish what's going on with VPNs. Thanks!
jtlawson commentedon Jan 24, 2017
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.
cgull commentedon Jan 27, 2017
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?
1 remaining item
Khalian commentedon Jul 5, 2019
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).
jtlawson commentedon Jul 8, 2019
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.
Khalian commentedon Jul 8, 2019
[comment redacted by Mosh maintainers -- your contributions are welcome, but assailing other participants in the discussion is not necessary]
keithw commentedon Jul 9, 2019
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.
Khalian commentedon Jul 9, 2019
@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?
keithw commentedon Jul 9, 2019
Huh, I'm confused -- if ping is getting an error message, does
mosh-clientalso 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
But maybe the
mosh-clientis doing the right thing but it's themosh-serverthat 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.).
Khalian commentedon Jul 9, 2019
"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.
dm1090 commentedon Sep 30, 2020
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.
SuperBo commentedon Feb 24, 2021
Bump, VPN connection is very popular and I can’t use Mosh due to this error :(
achernya commentedon Jan 19, 2023
I think we should add a
--mtuargument tomoshto allow users to override the default MTU.[-]mosh does not reconnect over IPsec VPN[/-][+]Support smaller MTU when PMTUD is not available (e.g., some VPNs)[/+]Adaptively shrink the datagram MTU on a silent blackhole (fixes mobil…