2

Is there any way to know the public IP address of a Fortinet? There are many services such as icanhazip.com that tell you the current IP. In Linux, I would just run:

curl http://icanhazip.com

How could that be done with Fortinet (I am using a fortigat 200B in case it's noteworthy)

Some cases come to my mind:

  • I want to know the default GW I am using in a fast way
  • My DSL router is NATing, so I don't know directly the public IP address
  • Or IPs assigned as DCHP/PPPoE (as stated by @mbrownnyc)

Since it doesn't seem possible to use any form of curl/wget from the command line, another option would be to use nslookup (still not sure if it's a valid FortiGate command or only for some forti* products). See here for what I mean getting external IP

2
  • Do you want to grab the IP address of an interface that has an IP assigned via PPPoE or DHCP?
    – brandeded
    Aug 25, 2014 at 15:40
  • Added some more information
    – aseques
    Aug 27, 2014 at 9:29

8 Answers 8

4

There is a trick how to do it. It requires access to an SSH server available from the internet, preferably a linux machine. Simply log in to the server via SSH from the FortiOS CLI:

execute ssh user@sshserverip.

After logging in, drop off by typing exit and then log in again. You should then see a line saying:

Last login: date & time from: X.X.X.X.

X.X.X.X is your public address, when you logged in first time as described above.

The line "Last login:" is displayed by default unless it is deleted from SSH daemon config.

In case the server displays a DNS entry instead of the IP address, simply resolve it by typing nslookup dnsentry

2
  • not all DSL/cable/etc. ISPs have proper forward IPs for their reverse IPs on these dynamic IP systems;(
    – Hvisage
    Mar 22, 2019 at 13:06
  • You can execute ssh ident.me and save a roundtrip. api.ident.me for docs. Mar 5, 2022 at 2:22
2

Try "diagnose system waninfo ipify", it will show you the public facing IP address, GeoIP information and if you're on FortiGuard's blacklist. It also takes a source IP address as optional argument, if you have multiple internet lines. (tested on FortiOS 6.2)

1

I got here because I was wondering the same thing. Sure, you can just plug a PC into the internal port with a crossover cable, but I thought there had to be another way to get it.

So the solution was to have a computer on the external side of the fortigate with wireshark installed. Then in the fortigate command line, you

execute ping "computer IP address"

while the computer is running wireshark with the "icmp" display filter.

Now you should get the ping requests from the fortigate with its external IP adress.

1
  • Nice solution, I still need an external ssh box but currently it's not a problem
    – aseques
    Aug 27, 2021 at 10:20
0

I want to know the default gateway I am using in a fast way

Performing a traceroute to a known address out of the interface you wish to target, in my example Google DNS.

from the FortiOS CLI:

execute traceroute 8.8.8.8

My DSL router is NATing, so I don't know directly the public ip address

This is tricky, if not impossible from the FortiOS. Open to other responses as I could be missing something.

An alternate to just hitting a web site to get the IP you are accessing that site with, is to find a STUN/ICE client and find a public STUN/ICE server that will return the info you wish. But you can't do either of these things from the FortiOS.

Or IPs assigned as DCHP/PPPoE (as stated by @mbrownnyc)

The IP assigned to a Fortigate can be reviewed as follows:

show system interface

You can see this in the dope little video collection on the Fortinet site.

2
  • The traceroute might be a good option to find the defatult gw, at least you will know the wan interface, see on the original post another idea I had..
    – aseques
    Sep 1, 2014 at 10:48
  • take a look at execute in the docs to learn how to use nslookup. I had no idea about nslookup myip.opendns.com resolver1.opendns.com. That's great! Thanks.
    – brandeded
    Sep 2, 2014 at 12:07
0

If you have an external IP from your provider - I have one way to know it via CLI: important - after this line don't press enter, press ?

$ show system interface ?

So after this command you'll see the external address under wanX pppoe

1
  • Doesn't do all the features I need, it shows the interfaces ips, but doesn't hint the default gw, and doesn't work when behind a NAT device.
    – aseques
    Dec 18, 2015 at 16:34
0

Simply use FortiDDNS on the appliance in Network/DNS (use Fortinet DNS to use FortiDDNS)

enter a FQDN and apply. return to same place and you will see your WAN IP

1
  • In what version are you seeing this feature?, I'm on 5.6 and there's nothing like that in Network -> DNS
    – aseques
    May 11, 2020 at 12:54
0

By just doing:

diagnose ip address list
1
  • It doesn't work when you're behind a NAT
    – aseques
    Aug 27, 2021 at 10:17
0

Or just get it from the Status page on the dashboard of the Fortigate if you can access it via the FortiCloud remote access console

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .