> -----Original Message----- > From: linux-discussion-bounce@xxxxxxxxxxxxx > [mailto:linux-discussion-bounce@xxxxxxxxxxxxx]On Behalf Of John Madden > Sent: Tuesday, August 27, 2002 9:37 PM > To: linux-discussion@xxxxxxxxxxxxx > Subject: [Linux-Discussion] Re: DHCP Server Detection > > > > > The problem is that they have a M$ DHCP server in the lab that they > > occasionally need to turn on for the W2K classes. I would like to write > > a cron job script that will bring the my box's DHCP service down when > > the M$ DHCP server comes up. > > Can the MS folks be given their own subnet (or even physical > segment), and > only answer DHCP queries for their own machines? Especially if this is a > lab environment where they'll be playing with stuff, and even moreso > because it's an MS DHCP server (think active directory, non-RFC stuff, > etc.), I don't think you'd want to be bringing your own DHCP box up and > down all the time, unless it's not a big deal that the machines have no > connectivity at times. I honestly don't know how well > already-leased IP's > get transferred from one client and server to another - YMMV. The MS folks have their own physical segment and use their own private IP address range. That is why I built them a simple firewall/nat box. The box let's them have outside connectivity with their private addresses and also keeps their their M$ DHCP server from answering requests coming from our network. We have a DHCP server that services the Region. This is not the box I was talking about bringing down. I'm going to add dhcpd to the firewal/natbox that sits between their network and ours. It will only hand out private addresses for their segment. They need it's service about 3/4 of the time, but there will be time periods (weeks at a time) that they need to exclusively use their DHCP server. That's why I would like the Linux box to occasionally check to see if the M$ server is up. > > > My thinking is that I could write a cron job script to occasionally > > check port 68 on the M$ DHCP server. If the port is active the script > > would bring the Linux DHCP down. If the port isn't answering DHCP > > requests it would bring the Linux DHCP service up. > > (Isn't it port 67?) > > 67 and 68 one is server side, one is client side. Maybe I have them backward. > #!/usr/bin/perl -w > use strict; > use IO::Socket; > > my $sock = IO::Socket::INET->new( > PeerAddr => 'ms-crapper', > PeerPort => '67', > Proto => 'udp') || exit; > > print "Killing dhcpd...\n"; > system("killall -15 dhcpd"); > > > The idea is that if a socket doesn't exist, we just exit (you may want to > add code there to make sure dhcpd is still running at this point, in case > we've previously killed it), and otherwise, we kill off our own dhcpd. > > John > > > > Cool. This gives me something to start off with. I'm getting a little handle on shell scripting, but since I'm still relatively new to much of this, I'll have to figure out the perl side of things. I appriciate the help. If you think of anything else please let me know. Thanks again, David > > -- > # John Madden weez@xxxxxxxxxxxxx ICQ: 2EB9EA > # FreeLists, Free mailing lists for all: //www.freelists.org > # UNIX Systems Engineer, Ivy Tech State College: http://www.ivytech.edu > # Linux, Apache, Perl and C: All the best things in life are free! > >