LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-26-2008, 11:28 AM   #1
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Rep: Reputation: 0
Trying to setup a DHCP server


Hi Guys,

totally new to Linux Fedora Core 5 just been playing with it seriously since 3 months, Im using a laptop a toshiba l20 with
40G HDD
512 RAM
INTEL Centrino 1.6 Ghz Processor
Realtek NIC
Wireless NIC - > not recognized by linux doesnt bother me for now

Ok I have installed DHCP ISC 3 and using webmin to configure DHCP.

First question : Does a machine need to have 2 ethernet cards to be used as DHCP server.

if yes then Ill have to wait till I buy a Desktop or is there a workaround as this laptop is inherited from a friend.

if not then
Second question: where am i going wrong. I have assigned a static Ip to eth0 from networking configuration
eth0 IPaddress : 192.168.1.0
netmask: 255.255.255.0
broadcast: 192.168.1.255
activate at boot yes

DHCP server settings
DHCP listening interface eth0
DHCP subnet 192.168.1.0
range 192.168.1.200 to 210
gateway : 192.168.1.0

please dont be angry with me if Ive messedup in any way.

Regards
noob
 
Old 04-26-2008, 03:57 PM   #2
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
There is no need to have more than one network interface to support DHCP, although if you only have a laptop, it is not immediately obvious what else might need the DHCP services. If you have a network printer, you could just assign it a static address and be done with it.

Usually, people choose to put the DHCP service up on a boundary machine, which does have 2 ports: one for the LAN (Private Network), and one for the public Internet. But that is more a convenience, since such a machine tends to stay up for long periods.

As to your second question, the first thing that appears to be odd is your choice of address for your laptop. For largely historical (hysterical?) reasons, host number 0 is not used. Some software will allow its use as a legal host on a network, and some will not. Therefore, it is common practice to start with host number 1; for an 8-bit subnet, which you have (netmask 255.255.255.0), the last host number you can assign is 254, because 255 is reserved for subnet broadcasts. Thus, my recommended IP address for your laptop is 192.168.1.1.

Secondly, you have specified the laptop address as a gateway. This is wrong, since the laptop has only a single interface, and cannot be a gateway to other networks. Are you depending on a router box to give you access to the Internet? If so, the gateway address should be the address of that box's Private Networking port (which might be 192.168.1.1; if so, choose a different address for the laptop).

If you make these change on your laptop and still have troubles, please post again, describing what is not working.
 
Old 04-26-2008, 10:38 PM   #3
marquardl
Member
 
Registered: Apr 2008
Posts: 100

Rep: Reputation: 15
router

Maybe you want explicitly learn how to run a DHCP server, but if that's not the case, then you should rather buy some router switch with 4 or 5 ethernet ports. That router would be your gateway and also function as the DHCP server for your network (which currently consists of your laptop only). It will be much easier for you to build a small home network that way and you don't have to keep your laptop switched on all the time.

Linux

Last edited by marquardl; 05-01-2008 at 04:22 AM.
 
Old 04-27-2008, 12:39 AM   #4
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by marquardl View Post
Maybe you want explicitly learn how to run a DHCP server, but if that's not the case, then you should rather buy some router switch with 4 or 5 ethernet ports. That router would be your gateway and also function as the DHCP server for your network (which currently consists of your laptop only). It will be much easier for you to build a small home network that way and you don't have to keep your laptop switched on all the time.

Bye,
M
Ok Guys thanks for the suggestions given so far. Ill elaborate my setup again. Ive got 2 laptops one running XP Pro and the other Fedora 5. ive got the fedora hooked up to an intelligent networks 5 port switch and want to make the laptop a DHCP server to for learning. As suggested by dkm999 Ive changed the settings from 192.168.1.0 to .1 and the bcast to .254 now I was trying to setup the machine as a default gate way as well but realized that I needed a second interface on the laptop. Ive already got a wifi router but am not able to load the ndis wrapper for my WLAN card on the laptop which if I could would have been awesome. but i think this should give you a clearer picture. Now im going to run a rather long cable and connect my fedora machine to the router making it the gateway and disable the dhcp on the router and hopefully see if it works.
 
Old 04-27-2008, 02:54 AM   #5
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Original Poster
Rep: Reputation: 0
Ok after the resets this is what I have done.

I have found a rickety old router modem a speedstream 4200 to act as router. with Ip 10.0.0.138
the Ip address I have given to eth0 is 10.0.0.2 netmask as 255.255.255.0 and broadcast as 10.0.0.254
I have created a subnet 192.168.1.1 and netmask as 255.255.255.0 and listening on eth0
the range I ve given is 192.168.1.10 to 192.168.1.20
I have set the modem router to dhcp relay and the relay Ip address is 10.0.0.138
Ok
now I get the error subnet 192.168.1.1 netmask 255.255.255.0: bad subnet number/mask combination
subnet 192.168.1.1 netmask 255.255.255.0
^
 
Old 04-27-2008, 02:55 AM   #6
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by dkm999 View Post
There is no need to have more than one network interface to support DHCP, although if you only have a laptop, it is not immediately obvious what else might need the DHCP services. If you have a network printer, you could just assign it a static address and be done with it.

Usually, people choose to put the DHCP service up on a boundary machine, which does have 2 ports: one for the LAN (Private Network), and one for the public Internet. But that is more a convenience, since such a machine tends to stay up for long periods.

As to your second question, the first thing that appears to be odd is your choice of address for your laptop. For largely historical (hysterical?) reasons, host number 0 is not used. Some software will allow its use as a legal host on a network, and some will not. Therefore, it is common practice to start with host number 1; for an 8-bit subnet, which you have (netmask 255.255.255.0), the last host number you can assign is 254, because 255 is reserved for subnet broadcasts. Thus, my recommended IP address for your laptop is 192.168.1.1.

Secondly, you have specified the laptop address as a gateway. This is wrong, since the laptop has only a single interface, and cannot be a gateway to other networks. Are you depending on a router box to give you access to the Internet? If so, the gateway address should be the address of that box's Private Networking port (which might be 192.168.1.1; if so, choose a different address for the laptop).

If you make these change on your laptop and still have troubles, please post again, describing what is not working.
Ok after the resets this is what I have done.

I have found a rickety old router modem a speedstream 4200 to act as router. with Ip 10.0.0.138
the Ip address I have given to eth0 is 10.0.0.2 netmask as 255.255.255.0 and broadcast as 10.0.0.254
I have created a subnet 192.168.1.1 and netmask as 255.255.255.0 and listening on eth0
the range I ve given is 192.168.1.10 to 192.168.1.20
I have set the modem router to dhcp relay and the relay Ip address is 10.0.0.138
Ok
now I get the error subnet 192.168.1.1 netmask 255.255.255.0: bad subnet number/mask combination
subnet 192.168.1.1 netmask 255.255.255.0
 
Old 04-27-2008, 11:20 PM   #7
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
Errr, what is it that produces this error message? Usually, when you give address and subnet masks together in one command, the host-number part (which corresponds to the zeroes in the netmask) is 0.
 
Old 05-08-2008, 08:24 AM   #8
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Original Poster
Rep: Reputation: 0
Ok Finally

I have been successful in setting up my DHCP on eth0. Thanks for all the help just one thing though
I have assigned a static ip address for eth0
my /etc/sysconfig/network-scripts/ifcfg-eth0 looks like this
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
MACADDR="xx:xx:xx:xx:Xx:xx"
DHCP_HOSTNAME="example"
IPADDR=192.168.1.221
BCAST=192.168.1.255
NETMASK=255.255.255.0

my etc/dhcpd.conf
ddns-update-style interim;
default-lease-time 86400;
max-lease-time 86400;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1;
option domain-name"ex";
authoritive;

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.200 192.168.1.222;
range 192.168.1.150 192.168.1.190;
option netbios-name-servers 192.168.1.1;
}

after updating the eth0 I do ifdown eth0 and then ifup eth0
it retains the static ip address for a while and the DHCP works fine after dhcpd
but after about a minute the ip address reverts back to 169.254.206.113 Bcast .255.255 mask etc etc.

and my DHCP server fails. Can anyone explain why this is happening PLEASE
 
Old 05-08-2008, 04:06 PM   #9
jonlake
Member
 
Registered: Apr 2004
Distribution: Slackware 11.0, Gentoo
Posts: 252

Rep: Reputation: 31
To me what it sounds like is happening, is when you run the scripts to bring your interface down/up, it is trying to get an IP address from a DHCP server when it comes back up, but times out, which is why you are getting the 169 address. Until it times out, it will retain the 192.168.0.1 address.

Post the contents of /etc/network/interfaces as that is what ifup reads for it's configuration.
 
Old 05-08-2008, 08:50 PM   #10
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Original Poster
Rep: Reputation: 0
Ok I think I have resolved the issue of the DHCP dropping out as well, it was the GUI network manager that is next to the clock in the top right hand corner. after I do ifup eth0 the ip is set for eth0 but then the network manager had some gui settings whcih kept reverting it to the original the 169 address. I have disabled the GUI network manager and just used command line to over ride all settings its working fine now.

Thanks for all the help. Just one question tho. How do I add the DHCP server to start on Boot as after the boot I manually give the dhcpd command and then it starts.
 
Old 05-08-2008, 10:42 PM   #11
jonlake
Member
 
Registered: Apr 2004
Distribution: Slackware 11.0, Gentoo
Posts: 252

Rep: Reputation: 31
Fedora has chkconfig to help control startup scripts.

sudo chkconfig dhcpd on

see man chkconfig for more information on chkconfig usage

Last edited by jonlake; 05-08-2008 at 10:47 PM.
 
Old 05-09-2008, 12:02 AM   #12
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Original Poster
Rep: Reputation: 0
HI Thanks for getting back, Ive done chkconfig --list and it shows me everything except dhcpd. SO I did chkconfig --add dhcpd and I get an error service dhcpd does not support chkconfig.
 
Old 05-09-2008, 12:26 AM   #13
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
This is a pretty easy one to fix. What chkconfig is really saying is that it cannot find a line in the control script for dhcpd that tells it what to do. You can fix this with your favorite text editor. Open the file /etc/rc.d/init.d/dhcpd, and make the beginning of that file look like this:
Code:
#!/bin/bash
#
# chkconfig: 345 65 35
# description: dhcpd provides access to the Dynamic Host Control Protocol
Then give the command
Code:
#chkconfig dhcpd reset
This will cause the init stuff to be set right so that dhcpd will run in runlevels 3, 4, and 5. (Normally, your system runs in level 5).

HTH
 
Old 05-09-2008, 01:15 AM   #14
linuxnoob001
LQ Newbie
 
Registered: Mar 2008
Location: Australia
Distribution: Fedora Core 5
Posts: 14
Blog Entries: 1

Original Poster
Rep: Reputation: 0
hi,

I have done exactly as dkm999 suggested and it is still giving the same error, service dhcpd does not support chkconfig. Moreover when I try to issue the command dhcpd stop it gives me an error
No subnet declaration for stop(0.0.0.0).
**Ignoring requests on stop. If this is not what you want, please write a subnet declaration
in you dhcpd.conf file for the network segment to which interface stop is attached. **

Not configured to listen on any interfaces!

I have gone through the readme for the ISC dhcp-servef from ftp.isc.org and theres nothing about these issues except for a broadcast issue in Linux.
 
Old 05-09-2008, 10:05 AM   #15
jonlake
Member
 
Registered: Apr 2004
Distribution: Slackware 11.0, Gentoo
Posts: 252

Rep: Reputation: 31
Are you running the stop command on the dhcpd binary executable (/usr/sbin/dhcpd stop, or not specifying a path dhcpd stop) or on the startup script in /etc/init.d? You should be running it like this
Code:
 /etc/init.d/dhcpd stop
.

If you are running it on the /etc/init.d script, then you will have to fix that before the below will work. Also, if it is the /etc/init.d script that isn't working, post the contents of that script and we can see why you are getting that error.

If chkconfig isn't working, you can easily add dhcpd to startup on your own, by creating the symlinks in the /etc/rc.3 /etc/rc.4 /etc/rc.5 directories.

Code:
ln -s /etc/init.d/dhcpd /etc/rc.3/S65dhcpd
ln -s /etc/init.d/dhcpd /etc/rc.3/K65dhcpd
ln -s /etc/init.d/dhcpd /etc/rc.4/S65dhcpd
ln -s /etc/init.d/dhcpd /etc/rc.4/K65dhcpd
ln -s /etc/init.d/dhcpd /etc/rc.5/S65dhcpd
ln -s /etc/init.d/dhcpd /etc/rc.5/K65dhcpd
In case you don't know, when your system starts, it executes each script in /etc/rc.runlevel in alphabetical order that start with Snn. (If the script name were to start with a lowercase s or any other character besides uppercase S, it is skipped).
Note that I just randomly picked 65 for the place holder for dhcpd. So you will want to make sure that dhcpd is listed after your network script in each runlevel (since dhcpd uses your network adapter). You can do this by changing the number in the link to be greater than the number that your network script uses. Also, the K scripts are when you are shutting down, it Kills each service.
 
  


Reply

Tags
dhcp, server


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
DHCP/DNS Server Setup epicmove Linux - Networking 2 09-23-2007 03:45 PM
Setup a secure DHCP server carl0ski Linux - Networking 4 02-25-2007 08:44 PM
Trying to setup a DHCP server cwwilson721 Slackware 2 02-09-2006 02:22 AM
dhcp server setup help requested gonus Linux - Networking 5 07-09-2004 07:21 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration