Icinga / icinga-powershell-framework

This PowerShell module will allow to fetch data from Windows hosts and use them for inventory and monitoring solutions. Together with the Icinga Web 2 module, a detailed overview of your Windows infrastructure will be drawn.
MIT License
77 stars 33 forks source link

Feature Request: Self service API wrong IP for Hostadresse #721

Open tomabg opened 7 months ago

tomabg commented 7 months ago

Hi,

we are using Icinga director self service API and the Clients may have several (virtual) IP adresses.

Currently the Physical Adress is used for the Hostadresse field. So after Creation of a new host we need to change to the correct IP in Icinga Director

Better would be to find out the Local IP Adress from which the connection is done to Icinga Director for example like this:

PS C:\windows\system32> Get-NetTCPConnection -RemoteAddress  10.216.5.6

LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
------------                        --------- -------------                       ---------- -----       --------------
10.218.4.2                          51453     10.216.5.6                          443        CloseWait   Internet
10.218.4.2                          51452     10.216.5.6                          443        TimeWait

PS C:\windows\system32>

Maybe add a like if you have the same problem too.

tomabg commented 7 months ago

or maybe a better way:

PS C:\windows\system32> (Test-NetConnection -Port 443 -ComputerName 10.216.5.6).SourceAddress.IPAddress
10.218.4.2
PS C:\windows\system32>
LordHepipud commented 7 months ago

Thank you for your issue. There is already an Icinga function available which checks the best route to the target and uses the IP-Address from this interface

Get-IcingaNetworkInterface -IP <Icinga Director address>

Based on the networking routing configuration, it should report back the correct IP.

tomabg commented 7 months ago

the command Get-IcingaNetworkInterface returns in my case the physical adress but not the virtual adress(VPN)

PS C:\windows\system32> Get-IcingaNetworkInterface -IP 10.216.5.6 
192.168.178.32