/build/static/layout/Breadcrumb_cap_w.png

Quick script to rename Macs with the name defined on your DNS server.

Background: we've got several hundred machines with IP addresses assigned via the DHCP server. All the machines have named entries in the DNS server. My goal was to write a script that would rename the computer with the DNS name defined on the DNS server. Basically, does a reverse lookup of it's IP address, and uses the resulting DNS name to label the computer. Script assumes that ethernet 0 is being used.

 

# This queries the DNS server to get the computer name.

ip=`ifconfig en0 | grep "inet "|awk '{print $2}'`
asset=`host $ip |awk '{print $5 $6}' |awk -F. '{print $1}'`
echo Updating various computer names.
scutil --set HostName $asset
scutil --set ComputerName $asset
scutil --set LocalHostName $asset


Comments

This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ