Link to home
Start Free TrialLog in
Avatar of mark_06
mark_06

asked on

Bash script to domain lookup and change ACL

Hi,

I need to write a bash script to lookup a DNS name, let's say domain.dyndns.org, then compare it to a value in a file, if different update the file, then execute another script to ssh into a router and update an acl.

The purpose of this is to overcome a dynamic ip issue. I would want to run the script every 2 min or so.

Thanks
Mark
Avatar of Paul S
Paul S
Flag of United States of America image

have you tried a google search yet?

Here is what I found on google:

name lookup part:

do nslookup www.domain.com | grep Name | awk '{print $2}'; nslookup www.domain.com | grep Add | grep -v '#' | awk '{print $2}'; done

ssh part:
How to ssh from within a bash script? - Stack Overflow
http://stackoverflow.com/questions/1895185/how-to-ssh-from-within-a-bash-script

you'll have to modify as needed. we don't know how to modify your ACL since you have no info about it.
Why dont you plug it locally on router which in turn knows immediately when DHCP IP changed.
Avatar of mark_06
mark_06

ASKER

What I am looking to do is export the IP address value into a file or database which it will then compare to the record. If it is the same IP as in the record, it will end. If the IP changed then it will execute another script.

I can't do it locally on the router as the Cisco IOS for a 2800 will not do it.
Sounds absurd. How would you handle geographically distributed server pools?
Well 2 servers...
And you do dynamic DNS registration, but cannot send SNMP trap.
Avatar of mark_06

ASKER

I know it is absurd and very strange, however I do not need to worry about geographically distributed servers as the purpose is to allow 2 remote DSL connections with Dynamic IP's access to the corporate network (they don't want VPN) for VoIP. It's a crazy idea, however its more of a Proof of Concept rather than something that will be implemented on a wide scale.
ASKER CERTIFIED SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial