28. December 2015 · Comments Off on Config example of a Cisco router as a DNS server/forwarder. · Categories: Cisco, Networking · Tags: , , ,

For a quick and dirty DNS server you can configure a Cisco router. In the following config snippet I have configured a router as a DNS forwarder. Any ip host statements entered in the router will be resolvable by the clients.

!!! Host statements will be resolvable by clients !!!
ip host rtr.SITE.LAN
ip host gi0-0-0.SITE.WAN
ip host gi0-0-1.SITE.LAN
ip host servera.SITE.LAN
ip host serverb.SITE.LAN
ip host serverc.SITE.LAN
ip host serverd.SITE.LAN
ip host servere.SITE.LAN
!!! ACL to limit who can query the DNS server service !!!
ip access-list standard RFC1918-dns
!!! DNS name-list is used to control what zones/hosts can be queried !!!
ip dns name-list 1 permit .*
!!! Create a DNS view !!!
ip dns view default
 domain name-server
 domain name-server
 domain name SITE.LAN
 dns forwarding source-interface GigabitEthernet0/0/0
!!! Create a DNS view-list !!!
ip dns view-list LAN
 view default 1
  restrict source access-group RFC1918-dns
  restrict name-group 1
!!! Enable DNS server service and use the view-group !!!
ip dns server view-group LAN
ip dns server

If running an ISR g3 I recommend upgrading to at least 15.5(3)S1a.

28. December 2015 · Comments Off on Extract DNS Hostnames from rancid backups · Categories: Cisco, Linux, Linux Scripts · Tags: , , , ,
## To be ran from against rancid configs directory ##
# 1st loop greps and out all interfaces from the config.
# sed sterilizes the output, converts to lowercase and shorten interfaces names.
# 2nd loop prints the output and excludes uninteresting lines.
for CONFIG in ~rancid/rancid/configs/*
 do grep -e ^"interface" -e ^" ip address" $CONFIG 2> /dev/null |\
  tr -d '[:cntrl:]' | sed 's/interface /\n/g' | grep "ip address [1-9]" | awk '{print $1,$4}' |\
  sed 's/\(.*\)/\L\1/;s/vlan/vl/;s/loopback/lo/;s/gigabitethernet/gi/;s/fastethernet/fa/;s/port-channel/po/;s/tunnel/tu/;s/serialf/se/;s/dialer/di/' |\
  awk '{print "'$(basename $CONFIG)'",$0}'
 done | while read HOST INTERFACE ADDRESS
  do INTERFACE=`echo $INTERFACE | sed 's/\//-/g;s/\./-/g;s/:/-/g'`
   [ "$(host "$INTERFACE.$HOST" | awk '{print $NF}')" != "$ADDRESS" ] && { printf "ip host $INTERFACE.$HOST $ADDRESS\n"; }