You can use “nslookup” to get the IP address of the IoT Hub.
Ex: nslookup IoTHubname.azure-devices.net
Note that, once you have created an IoT hub in an Azure region, the IoT hub keeps the same IP address for the lifetime of that IoT hub. However, if Microsoft moves the IoT hub to a different scale unit to maintain quality of service, then it is assigned a new IP address.
The IP address prefixes of IoT hub are subject to change. These changes are published periodically via service tags before taking effect. It is therefore important that you develop processes to regularly retrieve and use the latest service tags. This process can be automated via the service tags discovery API . Note that Service tags discovery API is still in preview and in some cases may not produce the full list of tags and IP addresses. Until discovery API is generally available, consider using the service tags in downloadable JSON format.
Doc Reference: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-understand-ip-address
Source: MSDN