Skip to content

Instantly share code, notes, and snippets.

@mpontillo
Created April 27, 2017 21:16
Show Gist options
  • Save mpontillo/397da95888ac2de4bf83669931481daa to your computer and use it in GitHub Desktop.
Save mpontillo/397da95888ac2de4bf83669931481daa to your computer and use it in GitHub Desktop.
Gets a list of DHCP servers based on the current running DHCP clients.
#!/bin/bash
ps auxwwww | grep dhclient | grep -o '\-lf .*' | awk '{ print $2 }' \
| xargs -n 1 grep -o 'dhcp-server-identifier [A-Za-z0-9\.:]*' 2> /dev/null \
| sort -u | awk '{ print $2 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment