
| This forum is proudly powered by Scientific Linux 6 | SL website Download SL Help Search Members |
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
![]() ![]() ![]() |
| smithgcovert |
Posted: May 14 2011, 06:55 PM
|
|
|
SLF Rookie ![]() Group: Members Posts: 17 Member No.: 148 Joined: 10-May 11 |
So, I'm setting up my new SL 6 server, and one problem I've run into is that I can't find a new equivalent of something I used to do: I have a custom firewall script that I used to run each time the dhcp address to the internet changed. This worked great, as I just had to drop a reference to it in dhclient-exit-hook But the new way networks work in SL6 doesn't seem to have this same facility. I did find (through plain old trial and error) that if I dropped the script in /etc/dhcp/dhclient.d, that it would run each time the device goes up/down. That's getting me by right now, as my address doesn't really ever change. but it would be nice to figure out where I would put such function in the new environment. (I did a lot of searches, but everything I found referenced Fedora 12-14 and looked really hacky) Thanks, Greg |
|
| thomei |
Posted: May 14 2011, 07:28 PM
|
|||||
![]() SLF Member ![]() ![]() ![]() Group: Members Posts: 80 Member No.: 38 Joined: 12-April 11 |
SL 6 uses the NetworkManager by default. May you could turn it of. Or could write a script how monitors the address in /etc/resolv.conf . This could runs as a daemon. It could call your custom firewall script. To start the daemon add /etc/init.d/name (replace "name" with the name of your daemon.)
Create the daemon script itself: /bin/name
-------------------- thomei
think free, think Linux |
|||||
| smithgcovert |
Posted: May 15 2011, 04:13 PM
|
|
|
SLF Rookie ![]() Group: Members Posts: 17 Member No.: 148 Joined: 10-May 11 |
Hi Thomei, I might be able to use something like this. I can't monitor resolv.conf, because that stays constant. (I use an internal caching DNS server.) I could monitor the ip address changes, though instead. I also found that I can add a file named "dhclient-eth1.conf" to /etc/dhcp, and that file will be used to setup options for that dhcp client when that interface comes up. I figured for sure that there was at least some dhcp client option that I could use to run a script on IP change, but I haven't found it yet. Cheers, Greg |
|
| Jcink |
Posted: May 18 2011, 06:32 PM
|
|||
|
SLF IRC Team ![]() ![]() ![]() ![]() Group: Members Posts: 204 Member No.: 15 Joined: 10-April 11 |
This should work for you, I just made it. It requires you have PHP installed on your SL. Set up a cron to run this script every minute, 15 minutes, or what have you:
Try just running it once yourself from terminal to make sure it works. It should make a file called current_ip.txt; and the next time you run it, it should print "no ip change found." In the system(); call you can put the path to the script you want to run. |
|||
| smithgcovert |
Posted: May 19 2011, 09:50 PM
|
|
|
SLF Rookie ![]() Group: Members Posts: 17 Member No.: 148 Joined: 10-May 11 |
Cool -- Thanks! |
|
| aboron |
Posted: Oct 8 2011, 09:38 PM
|
|||||
|
SLF Newbie Group: Members Posts: 1 Member No.: 911 Joined: 8-October 11 |
I recently ran across the same trouble, needing to update some things whenever my home ISP shuffles me around. And since there are a million ways to solve this, I ended up writing a shell script. I made it pretty generic so I can reuse it on different configurations. Here's the main script I run from cron:
It tracks the last ip in a file you can specify on the command line, you can also specify the interface to check and the name of the script to run when it detects a change. In my case, I have it call this script:
Mod's edit: changed some of the words used of the second line. |
|||||
| smithgcovert |
Posted: Dec 8 2011, 02:38 AM
|
|
|
SLF Rookie ![]() Group: Members Posts: 17 Member No.: 148 Joined: 10-May 11 |
For those that may come back and find this again: I ended up finding a nice way to do this, that didn't require constantly monitoring the ip address. It turns out you can drop a script in this directory: /etc/dhcp/dhclient.d Whenever the dhcp client renews the ip address, it will call all of the scripts in that directory. For me, I just dropped a script in there named "hook.sh" that resets the firewall on dhcp renew. Cheers, Greg |
|
| helikaon |
Posted: Dec 9 2011, 10:15 AM
|
|
![]() SLF Moderator ![]() ![]() ![]() ![]() ![]() ![]() Group: Moderators Posts: 514 Member No.: 4 Joined: 8-April 11 |
Nice work guys
-------------------- |
|
![]() |
![]() ![]() ![]() |