Last active
August 2, 2016 18:03
-
-
Save carlosvargasvip/d95cf8634ab0aa12965f9362648178e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author: Carlos Vargas (ContainerKing.Ninja) | |
# Filename: /etc/dhcp/dhclient.d/hostname | |
# Purpose: Used by dhclient-script to set the hostname of the system | |
# to match the DNS information for the host as provided by | |
# DHCP. | |
# | |
hostname=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1 | awk -F'.' '{print $1"-"$2"-"$3"-"$4}') | |
echo $hostname > /etc/hostname | |
hostname $hostname | |
echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment