LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 02-25-2007, 09:29 PM   #1
jim_naisium
Member
 
Registered: Jul 2006
Posts: 74

Rep: Reputation: 15
Setting up Slackware DHCP server...


Hi,

I am trying to setup a Slackware 10.2 DHCP server to replace my Win2k box, I would like to leave Eth0 on DHCP so that it will grab an IP address from my cable modem.

I would then like Eth1 to run as the DHCP server and hand out IP addresses to the PCs on the network. I have tried a couple of different configs that I found online but so far nothing has worked.

LSPCI gives me:
Ethernet controller: Linksys NC100 Network Everywhere Fast Ethernet 10/100 (rev 11)
Ethernet controller: 3Com Corporation 3c905B 100BaseTX [Cyclone] (rev 34)

So I know that Slackware can see both cards.

IP ADDR gives me:
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,NOTRAILERS,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:50:04:61:8d:c7 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.236/24 brd 192.168.0.255 scope global eth0
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
link/ether 00:03:6d:1f:c8:91 brd ff:ff:ff:ff:ff:ff

So Eth0 is already acting under DHCP and getting an IP from my current Windows server.

Going by their MAC/Hardware addresses the 3com NIC is Eth0 and the Linksys is Eth1.

Any suggestions on how to get this working?
 
Old 02-25-2007, 09:36 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
first thing to do would be to get your LAN card properly IP-configured, then make sure you can ping to and from clients on the LAN... is that the step you are currently on?? once that's done, you'd just need to start configuring your DHCP daemon... slackware comes with dhcpd and dnsmasq - which one are you using??
 
Old 02-25-2007, 10:17 PM   #3
jim_naisium
Member
 
Registered: Jul 2006
Posts: 74

Original Poster
Rep: Reputation: 15
I have tried both, using RC.DHCPD and DNSMASQ.

RC.DHCPD when I run it says that it starts, but then when I do IP ADDR the ETH1 NIC is never assigned an IP address. On my Win2k box the 1st NIC gets its IP address from the cable modem, then through connection sharing the 2nd NIC ends up with 192.168.0.1 and then hands out .2, .3, .etc.

Is Eth1 supposed to get some kind of x.x.x.1 address or will it just show up in IP ADDR with no address at all but still function as a DHCP server, I guess I'm confused about this point, I know how it works in Windows just not in Linux, I'm assuming that they should work the same.

When I run DNSMASQ I get error: "Failed to bind listening socket for 192.168.0.58: address already in use.", if I move the network cable from Eth0 to Eth1 and run it again I still get the same error.

From what I have heard I would prefer to run DNSMASQ since it comes built into Linux instead of having to manually configure the files needed to make DHCPD work.
 
Old 02-25-2007, 10:37 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by jim_naisium
I have tried both, using RC.DHCPD and DNSMASQ.

RC.DHCPD when I run it says that it starts, but then when I do IP ADDR the ETH1 NIC is never assigned an IP address. On my Win2k box the 1st NIC gets its IP address from the cable modem, then through connection sharing the 2nd NIC ends up with 192.168.0.1 and then hands out .2, .3, .etc.

Is Eth1 supposed to get some kind of x.x.x.1 address or will it just show up in IP ADDR with no address at all but still function as a DHCP server, I guess I'm confused about this point, I know how it works in Windows just not in Linux, I'm assuming that they should work the same.
your LAN interface will need to be statically configured by you - it's a separate issue... just give it a proper IP/netmask and you're set... look in the /etc/rc.d/rc.inet1.conf file...

Quote:
When I run DNSMASQ I get error: "Failed to bind listening socket for 192.168.0.58: address already in use.", if I move the network cable from Eth0 to Eth1 and run it again I still get the same error.
please post the output of:
Code:
ifconfig
Code:
route -n
Quote:
From what I have heard I would prefer to run DNSMASQ since it comes built into Linux instead of having to manually configure the files needed to make DHCPD work.
not sure what you mean... dnsmasq is not built into linux in any way...

BTW to make dhcpd work you basically just need to edit the /etc/dhcpd.conf file (if it doesn't exist just create it)... here's an *example* of what one might look like, assuming the LAN interface has the IP of 192.168.1.1/24 and will function as the gateway for the LAN (it's pretty straight-forward):
Code:
ddns-update-style none;
subnet 192.168.1.0 netmask 255.255.255.0 {
       option routers 192.168.1.1;
       option subnet-mask 255.255.255.0;
       option domain-name "example.net";
       option domain-name-servers 192.168.1.1;
       option broadcast-address 192.168.1.255;
       range 192.168.1.2 192.168.1.254;
       default-lease-time 43200;
       max-lease-time 86400;
       }

Last edited by win32sux; 02-25-2007 at 10:42 PM.
 
Old 02-26-2007, 12:43 AM   #5
jim_naisium
Member
 
Registered: Jul 2006
Posts: 74

Original Poster
Rep: Reputation: 15
I have RC.INET1 setup statically for Eth1, here is what IP ADDR says:

1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,NOTRAILERS,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:50:04:61:8d:c7 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.182/24 brd 192.168.0.255 scope global eth0
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:03:6d:1f:c8:91 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global eth1

Here is IFCONFIG:

eth0 Link encap:Ethernet HWaddr 00:50:04:61:8D:C7
inet addr:192.168.0.182 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:571 errors:0 dropped:0 overruns:0 frame:0
TX packets:565 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:432525 (422.3 Kb) TX bytes:87416 (85.3 Kb)
Interrupt:7 Base address:0xec00

eth1 Link encap:Ethernet HWaddr 00:03:6D:1F:C8:91
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:51 dropped:0 overruns:0 carrier:102
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:5 Base address:0xe800

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:109 errors:0 dropped:0 overruns:0 frame:0
TX packets:109 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7724 (7.5 Kb) TX bytes:7724 (7.5 Kb)

Here is ROUTE -N:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1

192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo

0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0


Right now there is nothing plugged into Eth1 which is probably why it has NO CARRIER on it.

I believe that that was all that you wanted.

Last edited by jim_naisium; 02-26-2007 at 12:45 AM.
 
Old 02-26-2007, 01:01 AM   #6
jim_naisium
Member
 
Registered: Jul 2006
Posts: 74

Original Poster
Rep: Reputation: 15
More news...

I ran a cross over cable to one of my PCs and plugged it into Eth1, that PC is getting its IP address from the Linux box now 192.168.1.x instead of 192.168.0.x from the Windows server. /release /renew also worked, I can also ping the DNS name I gave the Linux box from the Win2k pc that is not the Windows server.

Only thing that doesn't work is that PC no longer has an Internet connection (surfing and IM's don't work), assuming that I need to set up some kind of routing table or I am missing something in the DHCPD.CONF file.

Config I am using is:
# dhcpd.conf
#
# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
#
ddns-update-style none;

subnet 192.168.1.0 netmask 255.255.255.0
{
range 192.168.1.100 192.168.1.200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option domain-name-servers 68.87.69.146, 68.87.85.98;
option routers 192.168.1.1;

host slackbox
{

fixed-address 192.168.1.7;
}
}
 
Old 02-26-2007, 01:41 AM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by jim_naisium
Only thing that doesn't work is that PC no longer has an Internet connection (surfing and IM's don't work), assuming that I need to set up some kind of routing table or I am missing something in the DHCPD.CONF file.
have you enabled IP forwarding?? check with:
Code:
cat /proc/sys/net/ipv4/ip_forward
if ip_forward is set to 0 then it's disabled... enable it with a:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
have you enabled masquerading?? check with:
Code:
iptables -L
Code:
iptables -t nat -L
if you don't have masquerading setup, this example /etc/rc.d/rc.firewall script should do it:
Code:
#!/bin/sh

IPT="/usr/sbin/iptables"
LAN_IFACE="eth1"
WAN_IFACE="eth0"

$IPT -P FORWARD DROP

$IPT -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

$IPT -A FORWARD -i $LAN_IFACE -o $WAN_IFACE \
-m state --state NEW -j ACCEPT

$IPT -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward

Last edited by win32sux; 02-26-2007 at 01:45 AM.
 
Old 02-26-2007, 06:51 PM   #8
jim_naisium
Member
 
Registered: Jul 2006
Posts: 74

Original Poster
Rep: Reputation: 15
Hi Win32sux,

I created /etc/rc.d/rc.firewall using your config file, after starting rc.dhcpd and rc.firewall DHCP and surfing both work fine now on the PC that I have plugged into Eth1,

Will probably take the Windows server down tonight and put this Linux box in its place, have to back up all the data files first though.

Where can I stick rc.dhcpd and rc.firewall so that they will both auto-start when the system boots up?


Thanks!
 
Old 02-26-2007, 08:45 PM   #9
jim_naisium
Member
 
Registered: Jul 2006
Posts: 74

Original Poster
Rep: Reputation: 15
Never mind, I figured it out, I stuck:

/etc/rc.d/rc.dhcpd start
/etc/rc.d/rc.firewall start

in rc.local and rebooted, it works fine now.


Thanks for all the help!
 
Old 02-27-2007, 07:46 PM   #10
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by jim_naisium
Never mind, I figured it out, I stuck:

/etc/rc.d/rc.dhcpd start
/etc/rc.d/rc.firewall start

in rc.local and rebooted, it works fine now.


Thanks for all the help!
no problem, you're very welcome...

for the record, i would like to mention that it's strange you had to edit rc.local for this... in fact, having your firewall script start so late in the startup process could be considered a secuirty issue...
 
Old 02-28-2007, 12:22 AM   #11
jim_naisium
Member
 
Registered: Jul 2006
Posts: 74

Original Poster
Rep: Reputation: 15
Hi again,

On this LAN I am not worried about it being a security issue (I'm the only Geek in the house (everyone else would be considered a "User")), but if there is a better way to do it how would I go about doing it?
 
Old 02-28-2007, 05:51 AM   #12
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by jim_naisium
On this LAN I am not worried about it being a security issue (I'm the only Geek in the house (everyone else would be considered a "User")), but if there is a better way to do it how would I go about doing it?
on slackware, making your /etc/rc.d/rc.firewall be executable is enough... slackware's network startup scripts are set to look for that file and execute it if present and executable...

BTW, here's a more complete version of the rc.firewall i posted:
Code:
#!/bin/sh

IPT="/usr/sbin/iptables"
LAN_IFACE="eth1"
WAN_IFACE="eth0"

echo 0 > /proc/sys/net/ipv4/ip_forward

$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT ACCEPT

$IPT -t mangle -P PREROUTING ACCEPT
$IPT -t mangle -P INPUT ACCEPT
$IPT -t mangle -P FORWARD ACCEPT
$IPT -t mangle -P OUTPUT ACCEPT
$IPT -t mangle -P POSTROUTING ACCEPT

$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT
$IPT -t nat -P OUTPUT ACCEPT

$IPT -F
$IPT -F -t nat
$IPT -F -t mangle

$IPT -X
$IPT -X -t nat
$IPT -X -t mangle

$IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

$IPT -A INPUT -i lo -j ACCEPT

$IPT -A INPUT -i $LAN_IFACE -m state --state NEW -j ACCEPT

$IPT -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

$IPT -A FORWARD -i $LAN_IFACE -o $WAN_IFACE \
-m state --state NEW -j ACCEPT

$IPT -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward
i highly recommend this one instead of the example i previously posted...

as for dhcpd, a line like this in your rc.local is what you'd want:
Code:
/usr/sbin/dhcpd eth1
notice how the interface you want the daemon to listen on is specified... also notice how no rc.dhcpd is used, as slackware 10.2 doesn't come with one...

Last edited by win32sux; 02-28-2007 at 09:17 PM.
 
  


Reply



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
Setting up a DHCP server MasterCephus Linux - Newbie 9 06-26-2005 07:41 AM
Setting up a DHCP server w/ the server on a wireless network Ionexchange Linux - Wireless Networking 0 05-08-2004 10:56 AM
Setting up DHCP server. joshnya Linux - Networking 1 10-12-2003 03:15 PM
Setting up a dhcp server PlatinumRik Linux - Networking 4 05-22-2003 01:50 AM
Setting up a DHCP Server bselzler Linux - Networking 2 08-07-2001 04:28 AM

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

All times are GMT -5. The time now is 07:53 PM.

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