ehowton (ehowton) wrote,
ehowton
ehowton

Query a List of Hostnames to Create /etc/hosts File

for x in `cat hostnames`;
do echo $(nslookup $x | grep -e Address | sed -n 2p | sed -r 's/.{9}//') $x ;
done >> hostfile

Or, add SHORTNAME and ALIAS:

for x in `cat hostnames`;
do echo $(nslookup $x | grep -e Address | sed -n 2p | sed -r 's/.{9}//') $x $(echo $x | sed "s/\..*//") $(echo $x | sed "s/\..*//").alt.fqdn;
done >> hostfile
Tags: linux, unix
Subscribe

  • Disable Automatic Repo Updates in SMT

    For SMT smt-3.0.37-52.23.6.x86_64 and greater only # vi /etc/cron.d/novell.com-smt-randomized Older versions remain in YAST --> Network Services…

  • Mount Stubborn VMFS as a DATASTORE (ESXi 6/7)

    I moved a formatted NVMe from one USB adapter to another USB adaptor and rebooted the host. ESXi GUI saw it as USB accessible storage, but would…

  • LinkedIN

    LinkedIN has this trend right now where you replace your PROFESSIONAL picture with one which more closely represents your fulltime telecommute…

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments