Netboot Internet Connection Problem with PXE/DHCP

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

Netboot Internet Connection Problem with PXE/DHCP

#1 Post by ecomoney »

Ive designed a netbooting cybercafe system where the client machines are booted via PXE/Netboot from a master PC. All of the machines are knitted together via a 4 port ADSL modem, with additional hubs in place for extra computers if needed.

Ive been experiencing some pretty strange faults which Ive only now got to the bottom of. After the clients have booted, in the startup script I issued the command

Code: Select all

dhcpcd eth0
To connect to (what I thought was) the router and gain an internet connection on the client P.C.'s. The problems I was having was that in some locations where I had this installed, the clients would connect every time, others not at all and other intermittently. What was happening was that, as well as the ADSL modem, the master computer was also running a DHCP server, to allow for PXE booting. Once the clients had booted and issued the "dhcpcd eth0" command, they were recieving an i.p. address from either the router or from the master computer...whichever replied first! :shock: If this was the master computer then the clients would not be able to access the internet...a big issue in a cybercafe!

For simplicity of use, I dont want to have to assign static i.p. addresses to the client computers (the idea is that they can be swapped in and out easily by untrained staff who dont know about router control panels and stuff). How would I get the clients to ignore the PXE DHCP server on the Master computer and always get an i.p. from the router instead?

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#2 Post by rcrsn51 »

There is a discussion here about how to configure the PXE server to use IP addresses from a router. In particular, set the "next-server" parameter to the router's IP address in /etc/dhcpd.conf

Or does your ADSL modem have an option for turning off DHCP?

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#3 Post by ecomoney »

So, it is possible to configure the dhcp server on the "master" machine to only accept connection requests that are from client machines attempting to boot, any others (i.e. from the dhcpc requests for an internet connection AFTER the cybercafe clients have booted).

In a setup where both the "master" computer and the netbooted client machines are attached to the same adsl router (with its own dhcp server), the master computer at startup must first discover the i.p. address of the ADSL router, and insert that value into the "next server" field of the master's /etc/dhcpd.conf. This way, DHCP requests from the client machines, once they have booted, will be forwarded automatically by the master machine to the ADSL router's DHCP service for i.p. address assignment.

Something tells me this is going to need a lot of "grep"'s..... :roll:

Im using the tftp server from here

http://www.murga-linux.com/puppy/viewto ... 8&start=15
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

raffy
Posts: 4798
Joined: Wed 25 May 2005, 12:20
Location: Manila

single dhcp server

#4 Post by raffy »

A single DHCP server should handle things, and that one already works with the TFTP server.

Could you not turn off the other DHCP server, and just identify the Internet gateway with

Code: Select all

route add default gw 192.168.0.1
Puppy user since Oct 2004. Want FreeOffice? [url=http://puppylinux.info/topic/freeoffice-2012-sfs]Get the sfs (English only)[/url].

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#5 Post by ecomoney »

Im designing this system with simplicity in mind. The idea is to simply plug the master computer into an standard adsl router, and have the other machines connected to it boot from it and gain their own internet connection automatically. If the systems were for my own use then I could do this.

At the moment the machines are connected after boot by using a samba shared drive on the master pc, with the clients attaching to it. Im wondering if I could use this to signal the master computer to temporarily pause the the dhcpcd server to allow the clients to get an i.p. via the router, then switch back on. The only problem with this (apart from it being "messy") would be that any other machines that were in the process of netbooting when the master computer dhcpcd server was paused would probably cease booting?

Im thinking "real world" when the cybercafe is opened in the morning and computers are simultaneously booting and getting their internet connections....this could delay the cybercafe startup by some time as each computer would have to be started one after another, rather than all at once. Perhaps the master computer could monitor the outgoing traffic on its ethernet port, and only when all the machines have finished netbooting would its dhcpcd server be shut off and all of the client machines could then aquire their internet connections from the router without interference?
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#6 Post by ecomoney »

After a bit more experimenting, Ive found that, on a network with both a pxe dhcp server and a router dhcp server, an i.p. is assigned randomly, rather than "first come first served". It should therefore just be a matter of running a script to connect via dhcp, check for a successful internet connection, and if one is not found try again (and again) until successful. Tommorow I will test it at the cybercafe and see how it works!
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#7 Post by ecomoney »

Heres the (very badly hacked) script

Code: Select all

#!/bin/sh

map_drives(){

# initially map drives
# if the folders already exist then this will produce a warning message
		mkdir /mnt/network/CYBERSERVER/
        mkdir /mnt/network/CYBERSERVER/remaster
		mkdir /mnt/network/CYBERSERVER/printq
		

		# connect to the print queue shared folder on the cyberserver
		busybox mount -t cifs -o username=printq,password=ecomoney //CYBERSERVER/printq /mnt/network/CYBERSERVER/printq

		# connect to the remaster shared folder on the cyberserver
		busybox mount -t cifs -o username=remaster,password=ecomoney //CYBERSERVER/remaster /mnt/network/CYBERSERVER/remaster
}

isconnected(){
	# beep -f 660 -l 250
	# gxmessage "wgettin google"	
	#Determine if google can be contacted
	/usr/bin/wget -q --tries=2 --timeout=3 http://www.google.com -O /tmp/index.google &> /dev/null &
        sleep 3
        killall wget
	# beep -f 770 -l 250
	# gxmessage "wgettin google done"
	if [ ! -s /tmp/index.google ];then
        # google index could not be downloaded, no connection
        echo "disconnected"
    else
	    # google index present, return "connected" instead
		echo "connected"
	fi
}

reconnect(){
	
     #   gxmessage "startin reconnect"
	# Kill/remove anything to do with the previous connection	
		
	 kill $( cat /var/run/dhcpcd-eth0.pid )
	 rm -f /var/run/dhcpcd-eth0.* 2>/dev/null
	 rm -f /var/lib/dhcpcd/dhcpcd-eth0.* 2>/dev/null  
	 rm -f /etc/dhcpc/dhcpcd-eth0.pid 2>/dev/null
	 rm -f /etc/dhcpc/dhcpcd-eth0.* 2>/dev/null
	 rm -f ./dhcpcd.log   

	# Auto connect to router with dhcpcd
		
	dhcpcd -d -t 10 eth0 >> ./dchpcd.log 
	# Test the new connection
	if [ $(isconnected) = "disconnected" ] ; then
	    # beep -f 440 -l 250
		echo "fail"
	else
	     # beep -f 880 -l 250
	     echo "success"
		 gxmessage "Connection established" &
		 sleep 2
		 killall gxmessage
         map_drives
    fi
	
}

map_drives

while [ 1 ]
do


#check for internet connection
if [ $(isconnected) = "disconnected" ] ; then

	# Attempt Reconnect
	if [ $(reconnect) = "fail" ];then	
	
	    # Reconnect failure beep
		# gxmessage "reconnect fail"
		beep -f 440 -l 250
	fi
fi

# Check connection every 3 seconds
sleep 3

done
Any improvements welcome!
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

#8 Post by ecomoney »

I know, its a netboot thing....thing is puppy has so much potential for running in netbooted mode. Its generally been just a thing thats been used for installing new computers or for restoring from backups...which is why there doesnt seem to be any documentation on the web about this issue. Im running fully fledged puppy in memory which is causing the proble. Also networking (and bash!) is a bit of a blind spot for me.

Heres the /usr/sbin/ppxe script which starts the server on the master computer

Code: Select all

#!/bin/sh
# MagicZaurus January 2009 for Puppy Linux GPL.
# Based on script from SLAX.
# Enhanced by Ecomoney August 2009

PXE_IP=$(ifconfig "$(ls -1 /sys/class/net | grep eth | head -n 1)" | grep "inet addr" | cut -d : -f 2 | cut -d " " -f 1)
IP_BASE=$(echo $PXE_IP | cut -d "." -f 1-3)

echo $PXE_IP
echo $IP_BASE

if [ "$PXE_IP" != "" ]; then
	case "$1" in
		start)
		    killall dnsmasq 2>/dev/null
			dnsmasq --enable-tftp --tftp-root=/root/tftpboot \
				--dhcp-boot=/pxelinux.cfg/pxelinux.0,puppypc,$PXE_IP \
				--dhcp-range=$IP_BASE.100,$IP_BASE.200,infinite --log-dhcp
			echo            "DHCP and TFTP server started, start your other computers via the network."
			gxmessage "DHCP and TFTP server started, start your other computers via the network."
			;;
		stop)
			killall dnsmasq 2>/dev/null
			echo            "DHCP and TFPT server stopped."
			gxmessage "DHCP and TFPT server stopped."
			;;
		restart)
			$0 stop
			$0 start
			echo            "TFTP Server Restarted"
			gxmessage "TFTP Server Restarted"
			;;
	esac
else
	echo "No IP assigned to network interface. Cannot start DHCP and TFTP server."
	gxmessage "No IP assigned to network interface. Cannot start DHCP and TFTP server. Please use the network connection wizard to connect to via Ethernet/LAN"
fi
basically, this gets the master computers assigned i.p address (got via dhcp from the router). Since most routers I have found give out addresses in the rang 192.168.1.1 thru 192.168.1.100, and address that is given out via the tftp dhcp server will be 192.168.100 thru 192.168.1.200. Therefore I suppose I could test for an i.p. address greater than 192.168.1.100 and assume that the dhcp request was resolved by the wrong server if this were the the case. The other thing to do would be to have a big toggling icon on the desktop of the master computer to turn the pxe/dhcp server function OFF/ON. That way the client computers would continue to try and reconnect until the operator toggled the ppxe/dhcpcd service OFF which would allow the clients to get the I.P. from the router. Another way would be for master computer to somehow be able to forward its own internet connection via the same port (i.p. masquerading?), so whichever dhcp server the clients connected to (the router or the master computer) they would still get an internet connection. I have done this between two ethernet cards on the same computer (internet connection sharing) but how to do it over just one I wouldnt know.
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

Master_wrong
Posts: 452
Joined: Thu 20 Mar 2008, 01:48

#9 Post by Master_wrong »

Hi ecomoney,

thank for tutorial, btw can these be used too
http://rom-o-matic.net/


thank you
Cluster-Pup v.2-Puppy Beowulf Cluster
[url]http://www.murga-linux.com/puppy/viewtopic.php?p=499199#499199[/url]

Post Reply