Solved

Bash script to domain lookup and change ACL

Posted on 2014-09-20
6
144 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 61

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 61

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 61

Accepted Solution

by:
gheist earned 500 total points
ID: 40335178
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now