Hello All,
Is there a way to check whether a machine has a static IP or is getting an IP via DHCP in the JSS? Any info is greatly appreciated.
Thanks!
Ed
Hello All,
Is there a way to check whether a machine has a static IP or is getting an IP via DHCP in the JSS? Any info is greatly appreciated.
Thanks!
Ed
Here's an Extension Attribute script that should give you this info. It may not always be 100% reliable just due to needing to use system_profiler. There may be a better binary that can get this info, but I'm not sure at the moment
#!/bin/bash
interface=$(netstat -rn 2>&1 | grep -m1 "default" | awk '{print $NF}')
interface_name=$(networksetup -listallhardwareports | grep -B1 "$interface" | awk -F': ' '/Hardware Port/{print $NF}')
interface_config=$(system_profiler SPNetworkDataType | grep -B2 "ConfirmedInterfaceName: $interface" | awk '/Configuration Method/{print $NF}')
echo "<result>${interface_name}: $interface_config</result>"
It should print back something likeWi-Fi: DHCP
orApple USB Ethernet Adapter: Static
etc.
If you need an explanation of how this all works or what it's doing, post back and I will add details.
Thanks so much for the response! I will try this out and post my results.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.