Posted on 11-15-2017 12:48 PM
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
Posted on 11-15-2017 01:25 PM
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.
Posted on 11-16-2017 06:43 AM
Thanks so much for the response! I will try this out and post my results.