Solved

How can I change my IP info on a daily basis?

Posted on 2002-05-17
6
237 Views
Last Modified: 2013-12-15
Currently, I have to do the following process manually, using the Mandrake
Config tools in X-Windows.  It takes me about 20 minutes.  Can you guys help
me figure out a script for the following:

- flush all IPtables rules (so the packet filters are not active)
- switch eth0 from a static IP to DHCP
- receive a DHCP IP address
- run a Perl Script that I have already
- switch eth0 back to a static IP
- restart my firewall.sh script to setup my packet filters again

I want to do the above on a nightly basis.  In Windows 2K, I would write a
batch file (using the netsh.exe command) and have the Scheduler service run
the batch file nightly.

In Linux, the scripting and scheduling look much different.

BTW, this is a Mandrake 8.1 box, P][-266, 64mb RAM, 4gb HD, running no
server services (no apache or whatnot).  It has 2 ethernet cards (eth0 and
eth1).


TIA!!!!!!!!!


0
Comment
Question by:cdub1234
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 38 total points
ID: 7020691
That's the hard way to do a firewall. I'd guess that you probably have a statement something like:

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4

where 1.2.3.4 is the IP you get from the DHCP assignment and then configure eth0 to use. When you have a dynamic IP you should use:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

so that iptables will track the changing IP that DHCP assigns to your outside interface. Obviously in that case you want to leave the outside NIC configured to use DHCP. There's no reason to go through the routine ao changing to DCHP to get the IP then configuring the system to use that IP statically when you can have iptables automatically adjust things as necessary to follow the changing IP.
0
 
LVL 6

Assisted Solution

by:st_steve
st_steve earned 37 total points
ID: 7036444
And the scheduler service on Linux is "crond" and the "scheduler config file" is at /etc/crontab

Add your commands, scripts (and commands posted by jlevie) in this file and it should fire up when the time is right. If you need to change runlevels to do the tasks you've posted above, make sure the crond is running in that runlevel (the easiest way is to use chkconfig to configure whether crond runs in a particular runlevel).
0
 

Expert Comment

by:CleanupPing
ID: 9077010
cdub1234:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 1

Expert Comment

by:drewber
ID: 9220481
This question has been classified abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.
 

Unless it is clear to me that the question has been answered I will recommend delete. It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

 
If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp
 
drewber
0
 
LVL 12

Expert Comment

by:paullamhkg
ID: 10380059
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: jlevie {http:#7020691} & st_steve {http:#7036444}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

paullamhkg
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

730 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