V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
a251922581
V2EX  ›  云计算

移动宽带, SSH 如果闲置十几分钟不敲命令, NAT 设备就会把链接的 NAT 表项删掉, SSH 就挂掉了,有办法吗?

  •  
  •   a251922581 · Oct 18, 2017 · 5347 views
    This topic created in 3118 days ago, the information mentioned may be changed or developed.
    每条链接的 NAT 表项对 NAT 设备性能和价格影响比较大吧,移动的宽带听说是经过了好几次 NAT 的。。为节约设备 NAT 并发资源,对超时的 NAT 表项就删除掉了。可是这个超时太短了,不知道有没有十分钟,SSH 开着,一查资料十几分钟,SSH 窗口就挂掉了。。
    NAT 表项删除后,后来的数据包到达 NAT 设备时因为查表没查到,就直接丢弃了,是不是这样。。所以 ssh 链接也不退出,就没反应了,得手动关掉终端窗口。等超时得几十分钟才能 Timeout,显示 broken pipe。
    PS: 浙江移动 100M 宽带,实测 NAT 限制数量在 2000 左右,就是到了 2000 个 TCP 并发链接后新的 TCP 链接就开不了了。
    14 replies    2017-10-21 14:20:35 +08:00
    Radeon
        1
    Radeon  
       Oct 18, 2017   ❤️ 1
    ssh -o ServerAliveInterval=60 [email protected]
    solos
        2
    solos  
       Oct 18, 2017   ❤️ 1
    ServerAliveInterval ?
    Smilecc
        3
    Smilecc  
       Oct 18, 2017   ❤️ 1
    一般的 SSH Client 都会有发送空包保持存活的功能吧。
    比如 Putty 在 Connection -> Sending of null packets to keep session active
    wsy2220
        4
    wsy2220  
       Oct 18, 2017   ❤️ 1
    echo "ServerAliveInterval 60" >> /etc/ssh/ssh_config
    stanjia
        5
    stanjia  
       Oct 18, 2017
    @Radeon
    @wsy2220 学到了
    EmmaSwan
        6
    EmmaSwan  
       Oct 18, 2017
    雙向六十秒,重刷次數調高
    des
        7
    des  
       Oct 18, 2017 via Android
    不然尝试 mosh ?
    erlinux
        8
    erlinux  
       Oct 18, 2017
    ping gov.cn
    likuku
        9
    likuku  
       Oct 18, 2017
    ssh 登上远端机器立即就起 screen,在 screen 里做事,就算这边断掉也无所谓。
    FullBridgeRect
        10
    FullBridgeRect  
       Oct 18, 2017 via Android
    @likuku tmux 更好用点
    luolufang
        11
    luolufang  
       Oct 18, 2017 via Android
    我也选 screen
    WoodenRobot
        12
    WoodenRobot  
       Oct 19, 2017
    我选 Tmux
    aphorism
        13
    aphorism  
       Oct 19, 2017
    一般使用 tmux,听说 Byobu 也不错。

    确实电信通等很多宽带运营商都有这个问题。
    purezhang
        14
    purezhang  
       Oct 21, 2017 via iPhone
    @likuku 嗯嗯,好办法
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2503 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 02:38 · PVG 10:38 · LAX 19:38 · JFK 22:38
    ♥ Do have faith in what you're doing.