V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
GeekN0m0r3
V2EX  ›  macOS

在 macOS 上用 ip 访问地址都会提示端口拒绝,但是输入设备名称就能访问是什么鬼

  •  
  •   GeekN0m0r3 · 2021-04-30 18:18:54 +08:00 · 3758 次点击
    这是一个创建于 1084 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近搞了一个联想的老笔记打算做家庭服务器,结果搞了一下午都没 SSH 登陆成功,用 192.168.xxx.xxx 的 IP 地址连接永远提示端口拒绝。最后灵光一现,用 ssh root@lenovo-v310 的设备名称去访问结果就连接成功了。这是什么情况? 然后我又拿我的谷歌云服务器试了一下,发现同样的情况,如果用 IP 提示错误,但是用网址去连接就能连接上。难道是什么地方的设置有问题吗? 系统是 macOS Big Sur 11.3 。

    11 条回复    2021-05-01 11:52:20 +08:00
    lcdtyph
        1
    lcdtyph  
       2021-04-30 18:31:14 +08:00 via iPhone
    是不是安装了代理类的 app 啊,clash 或者 surge 之类的
    可以试一下 ssh -v root@lenovo-v310 然后把 connecting to ...那行贴上来
    GeekN0m0r3
        2
    GeekN0m0r3  
    OP
       2021-04-30 18:43:07 +08:00
    @lcdtyph 正解。
    把 surge 和 zshrc 里的代理全关了之后就正常了...
    forelegance
        3
    forelegance  
       2021-04-30 21:51:44 +08:00
    大概率是 zsh,你把默认 SHELL 切换回 bash,可能就好了。我直接出现问题,是因为这个原因,.zshrc 中的配置文件
    GeekN0m0r3
        4
    GeekN0m0r3  
    OP
       2021-05-01 07:38:30 +08:00
    @lcdtyph 不过为什么开代理也会影响我用 IP 连接谷歌云的服务器呢。我在请求查看器里看到都是走了代理流量,用 IP 连接就会提示 kex_exchange_identification: Connection closed by remote host,用网址连接就正常。
    imtyz001
        5
    imtyz001  
       2021-05-01 09:29:10 +08:00
    @GeekN0m0r3 #4 我感觉是代理规则问题 可以看看规则里是怎么处理 IP 访问的
    lcdtyph
        6
    lcdtyph  
       2021-05-01 09:59:28 +08:00 via iPhone
    @GeekN0m0r3
    没有失败时 ssh -v 的日志所以不好说啊。不过据我所知 ssh 默认不理会环境变量中的*_PROXY 设置吧。
    GeekN0m0r3
        7
    GeekN0m0r3  
    OP
       2021-05-01 10:18:21 +08:00
    @lcdtyph
    OpenSSH_8.1p1, LibreSSL 2.7.3
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 47: Applying options for *
    debug1: Connecting to 34.92.189.190 [34.92.189.190] port 22.
    debug1: Connection established.
    debug1: identity file /Users/lawrence/.ssh/id_rsa type 0
    debug1: identity file /Users/lawrence/.ssh/id_rsa-cert type -1
    debug1: identity file /Users/lawrence/.ssh/id_dsa type -1
    debug1: identity file /Users/lawrence/.ssh/id_dsa-cert type -1
    debug1: identity file /Users/lawrence/.ssh/id_ecdsa type -1
    debug1: identity file /Users/lawrence/.ssh/id_ecdsa-cert type -1
    debug1: identity file /Users/lawrence/.ssh/id_ed25519 type -1
    debug1: identity file /Users/lawrence/.ssh/id_ed25519-cert type -1
    debug1: identity file /Users/lawrence/.ssh/id_xmss type -1
    debug1: identity file /Users/lawrence/.ssh/id_xmss-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_8.1
    kex_exchange_identification: Connection closed by remote host
    lcdtyph
        8
    lcdtyph  
       2021-05-01 11:05:25 +08:00
    @GeekN0m0r3 #7
    日志显示连接建立成功了,是开了增强模式么?
    还有用域名访问和 ip 访问走的规则和节点是相同的么,以及 ssh -v 域名 的时候 Connecting to 那行显示的 IP 是这个 IP 么
    GeekN0m0r3
        9
    GeekN0m0r3  
    OP
       2021-05-01 11:33:28 +08:00
    @lcdtyph
    好吧,问题找出来了。我用域名访问的时候,有一行 Authenticated to xxxxxx.com ([198.18.xxx.xxx]:22). 然后我再用这个 198 的 IP 去连接就能连接上了。太奇怪了,我谷歌云上显示的外部 IP 明明是 34 开头的。
    lcdtyph
        10
    lcdtyph  
       2021-05-01 11:38:40 +08:00
    @GeekN0m0r3 #9
    这是个 surge 返回的 fakeip 关掉 surge 是没法用这个 ip 访问的。感觉还是 surge 的规则出了问题
    GeekN0m0r3
        11
    GeekN0m0r3  
    OP
       2021-05-01 11:52:20 +08:00
    @lcdtyph 你这么一说我觉得可能是机场那边的问题了。因为我直接给 SSH 设置了一个专门的节点,请求查看器里能看到用 IP 或者网址都是走同一个节点。不过目前也没什么好的解决办法。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2692 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:46 · PVG 23:46 · LAX 08:46 · JFK 11:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.