Advertisement
Mava

dhclient hostname setting

Jan 27th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. /etc/dhcp/dhclient-exit-hooks.d/hostname
  2.  
  3. <FILE>
  4. #!/bin/bash
  5. # Mava was hier
  6.  
  7. if [ "$interface" != "eth0" ]
  8. then
  9.     return
  10. fi
  11.  
  12.  
  13. if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \
  14.    && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
  15. then
  16.         return
  17. fi
  18.  
  19. #echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address
  20. hostname=$(host $new_ip_address | cut -d ' ' -f 5)
  21. pure_host=$(host $hostname | cut -d '.' -f 1)
  22. echo $pure_host > /etc/hostname
  23. hostname $pure_host
  24. #hostname=$pure_host
  25. #echo $new_ip_address $hostname $pure_host >> /etc/hosts
  26.  
  27.  
  28. <EOF>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement