guyeuro
V2EX  ›  问与答

为何 ifconfig 看不到外网地址?

  •  
  •   guyeuro · Aug 1, 2017 · 8926 views
    This topic created in 3223 days ago, the information mentioned may be changed or developed.

    ssh 登录了一台远程服务器

    但是 ifconfig 下却看不到外网地址

    这是怎么回事?

    难道 ssh 登录 session 是转发到内网上的一台机器?

    那么如何查看到有外网 IP 网卡的那台机器呢?

    15 replies    2018-12-10 19:51:37 +08:00
    dr3am
        1
    dr3am  
       Aug 1, 2017
    1、你的服务器确定是连得公网?
    2、中间是否有 NAT ?
    trepwq
        2
    trepwq  
       Aug 1, 2017 via iPhone
    nat 的公网 ip 吧,阿里云就是,ifconfig 看到的是私有地址
    kaneg
        3
    kaneg  
       Aug 1, 2017 via iPhone
    很多云主机都是这种模式,叫弹性 IP
    a1044634486
        4
    a1044634486  
       Aug 1, 2017
    所谓的弹性 ip 都是这样
    mogita
        5
    mogita  
       Aug 1, 2017
    服务商技术实力、服务态度和细心程度所导致。
    可选解决方案:
    curl ifconfig.co
    xxhjkl
        6
    xxhjkl  
       Aug 1, 2017
    说的莫非是千( a )万( li )云?
    guyeuro
        7
    guyeuro  
    OP
       Aug 1, 2017
    @kaneg 不是云主机,是远程一个机房的机器
    guyeuro
        8
    guyeuro  
    OP
       Aug 1, 2017
    @dr3am 是连得公网,如何查看中间是否有 NAT ?
    julyclyde
        9
    julyclyde  
       Aug 1, 2017
    ifconfig 只能显示接口上配置的其中一个 IP
    你应该用 /sbin/ip addr 来查看
    如果有的话
    dr3am
        10
    dr3am  
       Aug 2, 2017
    @guyeuro 我说直接连得公网,而不是公网-防火墙 or 路由-服务器
    guyeuro
        11
    guyeuro  
    OP
       Aug 7, 2017
    @dr3am 不知道中间有没有防火墙和路由啊
    如何查看?
    guyeuro
        12
    guyeuro  
    OP
       Aug 7, 2017
    @julyclyde

    # /sbin/ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
    valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 0c:c4:7a:90:c0:4e brd ff:ff:ff:ff:ff:ff
    inet 172.10.10.11/24 brd 172.10.10.255 scope global eth0
    inet6 fe80::ec4:7aff:fe90:c04e/64 scope link
    valid_lft forever preferred_lft forever
    3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 0c:c4:7a:90:c0:4f brd ff:ff:ff:ff:ff:ff
    inet6 fe80::ec4:7aff:fe90:c04f/64 scope link
    valid_lft forever preferred_lft forever
    mofe
        13
    mofe  
       May 7, 2018
    ifconfig.co 被 block 了,访问不了,所以我造了一个新轮子 http://iiip.co/

    使用 curl iiip.co

    代码在这 => https://www.mofe.me/2018/0504/

    ps: 有需求在浏览器中获取当前用户的真实 ip,所以加了 cors 头,这样就可以通过 ajax 请求获取真实 ip 了
    mofe
        14
    mofe  
       May 7, 2018
    尴尬,习惯用 markdown 写,所以留了这么多空格。。。
    waytowayne
        15
    waytowayne  
       Dec 10, 2018
    @xxhjkl 阿里云在这方面很坑吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   868 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 20:19 · PVG 04:19 · LAX 13:19 · JFK 16:19
    ♥ Do have faith in what you're doing.