LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-03-2014, 10:09 AM   #1
5883
Member
 
Registered: Aug 2004
Posts: 173

Rep: Reputation: 0
can dhclient trigger actions when it gets ip from DHCP server ?


normally if eth cable up/down can trigger the scripts in the if-up.d, if-down.d.

Now sometimes our DHCP server is not good, you plugin your eth cable for your system, it won't get ip.
sometime later it gets ip.

when it gets it, is there a way i get notified and do some actions ?
 
Old 04-04-2014, 07:17 AM   #2
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,466

Rep: Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798Reputation: 2798
As far as I know, dhclient cannot do this. However, if you are using DHCP and getting DNS addresses, these will be saved in /etc/resolv.conf. You could monitor that file for changes using inotify.
 
Old 04-04-2014, 02:18 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,797

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
You didn't mention which distro you are using, but for the Red Hat family, if you have an executable script dhclient-exit-hooks in $(ETCDIR} (normally either /etc/dhclient or /etc), then it will be sourced by /sbin/dhclient-script each time a dhclient event occurs. Since it is sourced, not called, all of the internal variables in dhclient-script are available, in particular $reason, which might be "BOUND", "RENEW", "REBIND", etc. You'll need to look at /sbin/dhclient-script for further info.
 
Old 04-04-2014, 05:11 PM   #4
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
with stunnel on, it shows sth. like 127.0.0.1, not the real one.


Quote:
Originally Posted by allend View Post
As far as I know, dhclient cannot do this. However, if you are using DHCP and getting DNS addresses, these will be saved in /etc/resolv.conf. You could monitor that file for changes using inotify.


---------- Post added 04-04-14 at 05:12 PM ----------

looks like this is what i want, using ubuntu, where should it be pls ?

Quote:
Originally Posted by rknichols View Post
You didn't mention which distro you are using, but for the Red Hat family, if you have an executable script dhclient-exit-hooks in $(ETCDIR} (normally either /etc/dhclient or /etc), then it will be sourced by /sbin/dhclient-script each time a dhclient event occurs. Since it is sourced, not called, all of the internal variables in dhclient-script are available, in particular $reason, which might be "BOUND", "RENEW", "REBIND", etc. You'll need to look at /sbin/dhclient-script for further info.
 
Old 04-04-2014, 08:19 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,797

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
You couldn't find it?? /sbin/dhclient-script is in exactly the same place, and in the /etc/dhcp directory you will find subdirectories dhclient-enter-hooks.d and dhclient-exit-hooks.d, both with some scripts for you to look at. This is on a Ubuntu 13.04 Live CD.

Last edited by rknichols; 04-04-2014 at 08:28 PM. Reason: typo
 
1 members found this post helpful.
Old 04-07-2014, 05:38 PM   #6
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
found it, thanks so much !

Quote:
Originally Posted by rknichols View Post
You couldn't find it?? /sbin/dhclient-script is in exactly the same place, and in the /etc/dhcp directory you will find subdirectories dhclient-enter-hooks.d and dhclient-exit-hooks.d, both with some scripts for you to look at. This is on a Ubuntu 13.04 Live CD.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Automatically trigger actions on systemd's journal messages LXer Syndicated Linux News 0 10-08-2013 09:11 AM
LXer: Trigger keyboard and mouse actions with your voice and xdotool LXer Syndicated Linux News 0 09-06-2011 03:10 AM
dhcp server - can't figure out dhclient.conf for eth1 JoeBleaux Debian 1 04-06-2009 06:13 PM
Action trigger on DHCP lease Cidi Rome Linux - Networking 3 03-05-2008 12:14 PM
acpi actions don't trigger events xnomad Linux - Software 0 04-30-2007 11:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration