获取接口对应的公网IP

  1. 当FortiGate的WAN接口(配置私网IP)位于Internet设备(针对FortiGate的WAN接口做SNAT)后时,可以通过如下CLI命令获取WAN接口对应的公网IP。

    该CLI命令需要FortiGate可以正常解析并访问https://api.ipify.org

    diagnose sys waninfo ipify
    
  2. 如下所示:

    FortiGate # diagnose sys waninfo ipify
    Try to get my public IP through https://api.ipify.org with src_ip=0.0.0.0 device=unspecified vfid=0(root) ...
    
    Public/WAN IP: 60.247.121.226
    Location: 
            Latitude: 39.904202
            Longitude: 116.407402
            Accuracy radius: Unknown
            Time zone: Asia/Shanghai
    City: Beijing
    Subdivisions: 
            0: Beijing
    Country: China
    Postal: Unknown
            Code: Unknown
    Continent: Asia
    Registered country: Unknown
    ISP: Unknown
    
  3. 如果存在多个WAN接口连接,需要获取特定WAN接口对应的公网IP,请使用如下CLI命令,指定要获取对应公网IP的接口,或使用接口私网IP作为源IP去获取对应的公网IP。

    diagnose sys waninfo ipify <interface_name> | <source_IP_address>
    
  4. 如下所示:

    FortiGate # diagnose sys waninfo ipify wan
    Try to get my public IP through https://api.ipify.org with src_ip=0.0.0.0 device=wan vfid=0(root) ...
    
    Public/WAN IP: 45.62.167.221
    Location: 
            Latitude: 22.278320
            Longitude: 114.174690
            Accuracy radius: Unknown
            Time zone: Asia/Hong_Kong
    City: Hong Kong
    Subdivisions: 
            0: Hong Kong
    Country/Zone: Hong Kong
    Postal: Unknown
            Code: Unknown
    Continent: Asia
    Registered country: Unknown
    ISP: Unknown
    
    FortiGate # diagnose sys waninfo ipify 192.168.123.175
    Try to get my public IP through https://api.ipify.org with src_ip=192.168.123.175 device=unspecified vfid=0(root) ...
    
    Public/WAN IP: 123.112.242.161
    Location: 
            Latitude: 39.904202
            Longitude: 116.407402
            Accuracy radius: Unknown
            Time zone: Asia/Shanghai
    City: Beijing
    Subdivisions: 
            0: Beijing
    Country: China
    Postal: Unknown
            Code: Unknown
    Continent: Asia
    Registered country: Unknown
    ISP: Unknown
    

Copyright © 2024 Fortinet Inc. All rights reserved. Powered by Fortinet TAC Team.
📲扫描下方二维码分享此页面👇
该页面修订于: 2024-05-07 15:43:25

results matching ""

    No results matching ""