Click to See Complete Forum and Search --> : Executing a command when DCHP connects


deathmonger
06-19-2002, 02:15 PM
I need for my server to execute a command whenever it connects to the internet through DCHP, but I can't get it to do that. I know that ppp-up can be used for ppp connections, but I cant find a DCHP-up. I am using Redhat 7.2.

Thanks.

jumpedintothefire
06-19-2002, 05:54 PM
Have a look at:
http://www.ecst.csuchico.edu/~dranch/LINUX/TrinityOS/cHTML/TrinityOS-c-35.html

syn
06-20-2002, 04:23 PM
The redhat dhcp client is pump I believe. Just do a man pump and check that. Are you trying to email out the dhcp address it just got or something? you can do a mailx script in the rc.local file, I think that one runs last

ifconfig > /tmp/myip
mailx -s "Heres my ip" you@mail.com < /tmp/myip

deathmonger
06-20-2002, 08:32 PM
Sorry jumpedinthefire, I am using dchpcd. Well, I have a dchpcd folder. What I am trying to do is run a webserver on a dynamic cable connection. I can visit a website, and it will automatically update the dns record. I haven't been able to physically get to the computer, I will do that sometime in the near future. But, isn't there an ip-up thing that will automatically execute a script when a connection to the internet is detected? Or even something like the windows startup folder (sorry for mentioning windows, but I am a new...convert in need of help :)

cowanrl
06-20-2002, 09:02 PM
If Red Hat 7.2 is configured for DHCP, it will first try to use dhcpcd. If that fails, it will try pump. If it can't use pump either, then the interface won't get an IP address or be brought up.

When Red Hat 7.2 starts up, the script that starts networking in general is /etc/rc.d/init.d/network. It eventually calls /etc/sysconfig/network-scripts/ifup. That is the script that actually brings up the interfaces and tries to execute either dhcpcd or pump.

I'm not familiar with writing scripts in Linux but I know enough about programming to see you that you could modify ifup so that if dhcpcd was successful, you could execute your own code.

I'll leave the script writing to you.

[ 20 June 2002: Message edited by: cowanrl ]

jumpedintothefire
06-21-2002, 12:51 AM
Once you "update the dns record" the first time the only time you need to updated it is if your ip changes, correct??

Then /etc/dhcpc(d)/dhcpcd-eth0.exe is the perfect place to put the script, it only gets run if there is a change in your ip address. If missing created it, setting permissions/owner, better yet just make it a symlink to the real script....

To get your script to run on bootup /etc/rc.d/rc.local
is the equivalent to windows/startup ;)