Quantcast
Channel: THWACK: Message List - Network Configuration Manager
Viewing all articles
Browse latest Browse all 8827

Re: DNS server changes - challange

$
0
0

This can't be done simply in NCM.  I would do this in Expect as a first timer.

 

Here would be how (this is depending on the fact there is only ONE dhcp scope configured and that you want the first IP listed):

 

#!/usr/bin/expect

#set variables that are called by prefixing dollar signs

set pass "password"

set deviceList {hostnames or ips seperated by spaces}

 

foreach host [split $deviceList] {

     spawn ssh $host

     expect "word:"

     send "$pass\r"

     expect "#"

     send "show run | i dns-server\r"

     expect "#"

     set firstIP "blank"

     regexp {([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})} $expect_out(buffer) firstIP

     if {$firstIP != "blank"} {

          send "config t\r"

          expect ")#"

          send "ip dhcp pool DHCPPOOL1\r"

          expect ")#"

          send "no dns-server\r"

          expect ")#"

          send "dns-server $firstIP\r"

          expect ")#"

          send "end\r"

          expect "#"

          send "wr\r"

          expect "#"

          puts "$host Successfully updated DHCP scope"

     } else {

          puts "$host Failed to parse IP"

     }

     send "exit\r"

}


Viewing all articles
Browse latest Browse all 8827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>