Searching for hosts using subnet on non-primary interfaces

Problem:

I have two questions regarding subnets on non-primary interfaces.

1. API question
We have several multi-homed hosts. Using the API, I would like to retrieve host information for any hosts that have a NIC in a specific subnet.
I’ve reviewed /api/subnets/:id/interfaces, which returns the fqdn and the interface name, but when the interface is non-primary, I’m not sure how to reliably map it back to the parent host.
Is there a way to accomplish this through the API?

2. Web UI question
I’m trying to do something similar in the Foreman web UI. Is there a way to search for hosts based on a subnet assigned to a non-primary interface?
Using subnet.name in the search only seems to match the primary interface’s subnet. Is there a way to search for hosts by subnets assigned to secondary/non-primary interfaces?

Thank you — we greatly appreciate Foreman.

Expected outcome: I would like to resolve primary host information by search with a subnet on a non-primary interface.

Foreman and Proxy versions: 3.16.1

Foreman and Proxy plugin versions:

Distribution and version: Rocky 9.6

Other relevant data:

Starting with foreman-3.17, that api response should also include the host name and id[1]. Until you upgrade, the probably sanest workaround would be to pick all the mac addresses from those interfaces and then search for hosts using the has_mac key and pass it all the mac addresses. Something like has_mac ^ (41:be:cc:c9:31:8b, 10:17:4a:4d:24:3b, ...).

I’m afraid not. You can search for hosts by all interfaces only using the interfaces’ ipv4, ipv6 and mac addresses.

[1] - Making sure you're not a bot!

Thank you. I’ve just upgraded to 3.17.0, and I now see host_id and host_name in the results.
Very pleased. Thanks again. :slightly_smiling_face:

1 Like