Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
Hyjaal
New Contributor II

How do I retrieve the ip of an API interface?

Hello everyone :)

 

As the name suggests, I'm trying to recover the ip addresses of my fortigate's interfaces.

I found this command but it only returns the interface name: /api/v2/cmdb/system/interface/Overlay-A/

 

"results": [
{
"name": "Overlay-A",
"q_origin_key": "Overlay-A",
"q_limited_permission": true
}
],


I've seen in the GUI via the API Preview button that there are formats with ip, remote-ip, etc. fields, but the following command doesn't return anything satisfactory: /api/v2/cmdb/system/interface/Overlay-A?format=ip

"results":[
{
"q_limited_permission":true
}
],

 

Can you please help me with this?

 

Hyjaal

1 Solution
ozkanaltas
Valued Contributor III

Hello @Hyjaal ,

 

I tried with these curl commands, I can get my interface list with no problem.

 

curl -k -i -X POST https://x.x.x.x/logincheck -d "username=<USER_NAME>&secretkey=<USER_PASSWORD>" --dump-header headers.txt -c cookies.txt


curl -k -i -X GET https://x.x.x.x/api/v2/cmdb/system/interface -b headers.txt
If you have found a solution, please like and accept it to make it easily accessible to others.
NSE 4-5-6-7 OT Sec - ENT FW

View solution in original post

If you have found a solution, please like and accept it to make it easily accessible to others.NSE 4-5-6-7 OT Sec - ENT FW
4 REPLIES 4
ozkanaltas
Valued Contributor III

Hello @Hyjaal ,

 

If you send a request to your FortiGate like that you can access all interface configurations. 

 

https://x.x.x.x/api/v2/cmdb/system/interface?access_token=<YOUR_ACCESS_TOKEN_HERE>

 

If you want to get specific interface configuration detail, you can use this request.

 

 

https://x.x.x.x/api/v2/cmdb/system/interface/<INTERFACE_NAME>?access_token=<YOUR_ACCESS_TOKEN_HERE>

 

If you have found a solution, please like and accept it to make it easily accessible to others.
NSE 4-5-6-7 OT Sec - ENT FW
If you have found a solution, please like and accept it to make it easily accessible to others.NSE 4-5-6-7 OT Sec - ENT FW
Hyjaal
New Contributor II

I think my command is wrong because I always get the same thing despite several syntaxes:

 

Here is my commands :

 

#Recovering the token
curl -k -c fgtcookies_fg -d username=apiuser -d secretkey=apiuser https://X.X.X.X/logincheck

 

#Recovery of Overlay-A interface IP address
curl -s -b fgtcookies_fg -k -X GET -H "Content-Type: application/json" https://X.X.X.X/api/v2/cmdb/system/interface/Overlay-A?access_token=<token>

 

ozkanaltas
Valued Contributor III

Hello @Hyjaal ,

 

I tried with these curl commands, I can get my interface list with no problem.

 

curl -k -i -X POST https://x.x.x.x/logincheck -d "username=<USER_NAME>&secretkey=<USER_PASSWORD>" --dump-header headers.txt -c cookies.txt


curl -k -i -X GET https://x.x.x.x/api/v2/cmdb/system/interface -b headers.txt
If you have found a solution, please like and accept it to make it easily accessible to others.
NSE 4-5-6-7 OT Sec - ENT FW
If you have found a solution, please like and accept it to make it easily accessible to others.NSE 4-5-6-7 OT Sec - ENT FW
Hyjaal
New Contributor II

Hello @ozkanaltas,

 

I confirm that I get the information I want.

I'll find out what's wrong with my order.

 

Thank you and have a nice day :)

 

Announcements

Select Forum Responses to become Knowledge Articles!

Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.

Labels
Top Kudoed Authors