Advertisement
dak1n1

DNS/DHCP migration one-liners

Dec 20th, 2012
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.21 KB | None | 0 0
  1. == DNS/DHCP migration one-liners ==
  2.  
  3. -----------------------------------------------
  4. Generate a list of DNS reverse lookup pointers
  5. -----------------------------------------------
  6. # this creates something like:
  7. # 5    IN   PTR  host1.my.domain.com.
  8. # 6    IN   PTR  host2.my.domain.com.
  9. # 7    IN   PTR  host3.my.domain.com.
  10.  
  11. x=5; for host in $(<hosts.txt); do echo -e "$((x+y))\t\tIN\t\tPTR\t\t$host."; echo $((y++)) >> /dev/null; done; y=0
  12.  
  13. -----------------------------------------------------
  14. Generate new A-records from old ones, keeping CNAMEs
  15. -----------------------------------------------------
  16. # this creates something like:
  17. # host1    IN    A  192.168.1.5
  18. # host2    IN    A  192.168.1.6
  19. # host3    IN    CNAME host2
  20. # host4    IN    A  192.168.1.7
  21.  
  22. awk 'BEGIN {count=5} {if ( $4 ~ /192.168/ ) { count++; print $1,"\t",$2,"\t",$3,"\t","192.168.10."count } else print $1,"\t",$2,"\t",$3,"\t",$4;}' dns_A_records.orig
  23.  
  24. ---------------------------------------------
  25. Generate new DHCP entries from the old ones
  26. ---------------------------------------------
  27. # this will grab whole {blocks} of DHCP entries
  28.  
  29. for host in $(<hosts.txt); do awk "/$host/,/}/" /etc/dhcpd/vlan130.conf; done >> vlan150.conf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement