Skip to main content

Hi Team ,

 

How can i get F5 VIP Ip and Pool address details by NQE.

 

Thanks

Rohit

You can get it out of the data model.  This is a Export version I wrote of this query because I was adding it to a much larger report.  However, you can see that it uses the data model to get the information.

/**
* @intent Extract all NATs and VIPs.
* @description
* 1) NAT information from all the FWs rulres we see in the tool: Source ip, original destination ip, translated ip address, FW name, FW IP and MAC addresses used for the connection.
* 2) VIP information from all Load Balancers we see in the tool: Original VIP, All Destination IPs, LB name, LB IP and MAC address used for the connection.
*/

getIntVrf(device, ifaceList) =
foreach networkInstance in device.networkInstances
foreach interface in networkInstance.interfaces
let name = if isPresent(interface.subIfaceName)
then interface.subIfaceName
else interface.ifaceName
where name in ifaceList
select distinct networkInstance.name;

export vipIps(device: Device) =
foreach x in n1]
where device.platform.vendor not in nVendor.VERSA]
foreach natEntry in device.natEntries
where natEntry.natType == NatType.LB
let metadataMatches = natEntry.metadataMatches
let vrf = getIntVrf(device, metadataMatches.egressInterfaces)
foreach subnet in natEntry.headerMatches.ipv4Dst
where subnet != ipSubnet("0.0.0.0/0")
let address = address(subnet)
foreach rewrite in natEntry.rewrites
select {address: address, dstPool: rewrite.ipv4Dst, vrf};

// Begin Test NQE query
foreach device in network.devices
let output = vipIps(device)
foreach entry in output
select {
Device: device.name,
address: entry.address,
dstPool: (foreach x in entry.dstPool select x),
vrf: entry.vrf
}

 


Hi @Tyson Henrie , 

 

unfortunately the Query i am not able to run , can you please check its working for you.

 

Thanks

Rohit 


@Rohit_809 Kumar I apologize. That query runs for me.  I tried changing it to a parameterized NQE.  Maybe this one will work for you.

The parameter is a device name.  you can enter the parameter using the parameter button that will be next to the executer button.

getIntVrf(device, ifaceList) =
foreach networkInstance in device.networkInstances
foreach interface in networkInstance.interfaces
let name = if isPresent(interface.subIfaceName)
then interface.subIfaceName
else interface.ifaceName
where name in ifaceList
select distinct networkInstance.name;

@query
vipIps(device: Device) =
foreach x in 1]
where device.platform.vendor not in Vendor.VERSA]
foreach natEntry in device.natEntries
where natEntry.natType == NatType.LB
let metadataMatches = natEntry.metadataMatches
let vrf = getIntVrf(device, metadataMatches.egressInterfaces)
foreach subnet in natEntry.headerMatches.ipv4Dst
where subnet != ipSubnet("0.0.0.0/0")
let address = address(subnet)
foreach rewrite in natEntry.rewrites
select {address: address, dstPool: rewrite.ipv4Dst, vrf};

 


is it possible to get the details without put parameter, in just single table form ?


@Rohit_809 Kumar Give this a try.

 

/**
* @intent Extract all NATs and VIPs.
* @description
* 1) NAT information from all the FWs rulres we see in the tool: Source ip, original destination ip, translated ip address, FW name, FW IP and MAC addresses used for the connection.
* 2) VIP information from all Load Balancers we see in the tool: Original VIP, All Destination IPs, LB name, LB IP and MAC address used for the connection.
*/

getIntVrf(device, ifaceList) =
foreach networkInstance in device.networkInstances
foreach interface in networkInstance.interfaces
let name = if isPresent(interface.subIfaceName)
then interface.subIfaceName
else interface.ifaceName
where name in ifaceList
select distinct networkInstance.name;

// NQE query starts here
foreach device in network.devices
where device.platform.vendor not in nVendor.VERSA]
foreach natEntry in device.natEntries
where natEntry.natType == NatType.LB
let metadataMatches = natEntry.metadataMatches
let vrf = getIntVrf(device, metadataMatches.egressInterfaces)
foreach subnet in natEntry.headerMatches.ipv4Dst
where subnet != ipSubnet("0.0.0.0/0")
let address = address(subnet)
foreach rewrite in natEntry.rewrites
select { device: device.name, address: address, dstPool: rewrite.ipv4Dst, vrf }

 


Getting below error.

 

Oops! The query doesn’t work.

Address the following issues:

  • Line 6, character 4: token recognition error at: '\r'
  • Line 7, character 31: token recognition error at: '\r'
  • Line 8, character 53: token recognition error at: '\r'
  • Line 9, character 50: token recognition error at: '\r'
  • Line 10, character 50: token recognition error at: '\r'
  • Line 11, character 41: token recognition error at: '\r'
  • Line 12, character 38: token recognition error at: '\r'
  • Line 13, character 26: token recognition error at: '\r'
  • Line 14, character 40: token recognition error at: '\r'
  • Line 15, character 1: token recognition error at: '\r'
  • Line 16, character 25: token recognition error at: '\r'
  • Line 17, character 34: token recognition error at: '\r'
  • Line 18, character 51: token recognition error at: '\r'
  • Line 19, character 38: token recognition error at: '\r'
  • Line 20, character 37: token recognition error at: '\r'
  • Line 21, character 47: token recognition error at: '\r'
  • Line 22, character 62: token recognition error at: '\r'
  • Line 23, character 49: token recognition error at: '\r'
  • Line 24, character 38: token recognition error at: '\r'
  • Line 25, character 30: token recognition error at: '\r'
  • Line 26, character 37: token recognition error at: '\r'

Hi @Rohit_809 Kumar -

I packaged @Tyson Henrie ‘s query using the Export queries feature in the NQE library (see attached). Please use the Import queries function to add it to your NQE library. This will hopefully address the issue you’re experiencing. 

Thanks,

@davetee

 

 

 

 


Reply