Solved

Bash script to domain lookup and change ACL

Posted on 2014-09-20
6
159 Views
Last Modified: 2014-11-21
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
0
Comment
Question by:mark_06
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:Paul S
ID: 40334990
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.
0
 
LVL 62

Expert Comment

by:gheist
ID: 40335032
Why dont you plug it locally on router which in turn knows immediately when DHCP IP changed.
0
 
LVL 6

Author Comment

by:mark_06
ID: 40335135
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.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 62

Expert Comment

by:gheist
ID: 40335136
Sounds absurd. How would you handle geographically distributed server pools?
Well 2 servers...
And you do dynamic DNS registration, but cannot send SNMP trap.
0
 
LVL 6

Author Comment

by:mark_06
ID: 40335168
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.
0
 
LVL 62

Accepted Solution

by:
gheist earned 500 total points
ID: 40335178
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question