LinuxQuestions.org
Review your favorite Linux distribution.
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 04-11-2005, 03:26 PM   #1
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
DHCP and gateway routing problems (fixed!)


I'm not really a linux newbie, but I am a networking newbie. There's obviously something simple that I'm fundamentally misunderstanding here...

I've got a DLink router that connects to DSL for me and hands out IPs of the format 192.168.0.x (with subnet mask 255.255.255.0). That network has an iMac (192.168.0.100) and my Slackware gateway box, one NIC (eth0) of which has the address 192.168.0.102 assigned by the DLink, which is on 192.168.0.1, as you'd expect.

The other NIC on my slackware gateway I've set up as ifconfig eth1 192.168.1.1.

Here's my dhcpd.conf (slightly modified from earlier), Those two nameservers are my ISP's:
Code:
ddns-update-style interim;
ignore client-updates;

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-servers 206.47.244.12, 206.47.244.42;
        option ip-forwarding on;
        range dynamic-bootp 192.168.1.100 192.168.1.254;
        default-lease-time 90;
        max-lease-time 240;
}
As per this FAQ I've also
Code:
iptables -A FORWARD -i eth1 -o eth0
iptables -A FORWARD -i eth0 -o eth1
When I start dhcpd I get:
Code:
Listening on LPF/eth1/00:11:09:e9:61:e1/192.168.1.0/24
Sending on   LPF/eth1/00:11:09:e9:61:e1/192.168.1.0/24

No subnet declaration for eth0 (192.168.0.102).
** Ignoring requests on eth0.  If this is not what
   you want, please write a subnet declaration
   in your dhcpd.conf file for the network segment
   to which interface eth0 is attached. **
Which is what I want, right?

Now, eth1 is connected to a hub, and into that hub is plugged my iBook. I can get an IP lease 192.168.0.20 and connect to my gateway's services (like apache) as 192.168.1.1 but I can't route to anything on the internet on the rest of my LAN, I just get messages like "can't find host <domain>".

In case it matters:
Code:
root@gateway:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
So, where did I go wrong?

EditII: This looks to me pretty much identical to JordanH's setup, here

Last edited by michaelsanford; 04-13-2005 at 03:16 PM.
 
Old 04-13-2005, 02:38 AM   #2
chrisfirestar
Member
 
Registered: Sep 2003
Location: Adelaide, Australia
Distribution: Fedora/RH
Posts: 231

Rep: Reputation: 30
Why you need DHCP when your router should be doing this for you? I dont understand you setup. However this is my DHCP how to:

To configure DHCP we must create a conf file for DHCPD to read.

$ cd /etc/
$ vi dhcpd.conf

hit " i " to go into INSERT mode and enter the following:

ddns-update-style interim;
default-lease=time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
option domain-name-servers 202.189.32.28, 202.189.32.48;
# option domain-name “example.com”;

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.11 192.168.1.249;
}

now we must specify which ethernet card is going to be used for the internal (local) network. Do the following.

$ cd /etc/sysconfig/
$ vi dhcpd

# Command line options here
# Where eth# is eth card connected to the local network
# you want to use DHCP for


DHCPDARGS=eth1

Now you are finishing with DHCP. If you turn on a client machine that's connected to the server it should be assigned an IP address within the range we have specified.

Last edited by chrisfirestar; 04-13-2005 at 02:40 AM.
 
Old 04-13-2005, 03:56 AM   #3
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

the iptables rules you've entered should output some erros :
they should be :
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -o eth0 -i eth1 -j ACCEPT

Hopefully, you don't need them : the defualt behaviour of iptables is to accept all trafic... so unless you configured other iptables rules, you can delete these two from your config script.

I think the problem might be solved by :
echo 1 > /proc/sys/net/ipv4/ip_forward

the value in this file is used to permit/deny the kernel to forward packets from an interface to another : ie behaving as a (simple) router.
 
Old 04-13-2005, 11:22 AM   #4
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Original Poster
Rep: Reputation: 30
chrisfirestar, I am doing this to test my gateway configuration before I deploy it elsewhere as a primary router; that is a good question though

fr_laz, perhaps it's a problem with my route, because ip_forward is indeed 1. And the firewall rules didn't output any errors, hmm. I altered them as you specified nonetheless.

I can connect to my gateway wired (through a hub) and obtain an IP address in the range specified by DHCP (192.168.1.245). Then, I can hit the gateway's web server at the IP in the range (192.168.1.1 on eth1) but I can't connect to it as 192.168.0.102 (it's address on eth0) or my router (192.168.0.1) or anything past the linux gateway for that matter.

It's just simply /not/ forwarding ip4 packets. Did I forget to compile something into the kernel? If so, what would it be?
 
Old 04-13-2005, 02:17 PM   #5
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Original Poster
Rep: Reputation: 30
Definately strange!

EDIT: I got it working! I'm a bit of a dumbell, it was my netmask that was wrong.
My NIC was enabled as
Code:
ifconfig eth1 192.168.1.1 netmask 255.255.255.0
when it should have been
Code:
ifconfig eth1 192.168.1.1 netmask 255.255.0.0
Something that I missed pretty easily and only ended up noticing because of this example.

Now, to go take off my 1337 black feora and go hide in my hoodie...and try and write a term paper that aims to be as elaborated as this thread was.

Original message follows:
Here's an update, it's still not routing. DHCP seems to be working properly, though perhaps it's dhcpd that's not telling the iBook client how to route to the internet.

(current) dhcpd.conf
Code:
ddns-update-style interim;
ignore client-updates;
default-lease-time 90;
max-lease-time 240;

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-servers 206.47.244.12, 206.47.244.42;
        option ip-forwarding on;
        range 192.168.1.100 192.168.1.110;
}
(current) dhcpd output
Code:
Listening on LPF/eth1/00:11:09:e9:61:e1/192.168.1.0/24
Sending on   LPF/eth1/00:11:09:e9:61:e1/192.168.1.0/24

No subnet declaration for eth0 (192.168.0.50).
** Ignoring requests on eth0.  If this is not what
   you want, please write a subnet declaration
   in your dhcpd.conf file for the network segment
   to which interface eth0 is attached. **
route output
Code:
root@gateway:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         192.168.0.1     0.0.0.0         UG    1      0        0 eth0
IP lease info on my iBook (dhcp client)
Code:
IP: 192.168.1.110
Netmasl: 255.255.255.0
Router: 192.168.1.1
There's no /etc/sysconfig folder in Slackware so I've just omitted that step of dhcp leasing since dhcpd seems to figure it out at startup.

As before, I can connect to 192.168.1.1's web server but I can't connect to anything past it. That surely means the gateway is not routing packets between eth1 to eth0.

I have no firewall rules at all on the gateway, then I had fr_laz's example, neither of which helped (as I , and fr_laz, expected).

I just recompiled kernel 2.6.11.7 and made sure to compile-in what I thought would be all the necessary IP Filtering and iptables modules, and of course anything with "masquerade" or "nat" in the description.

Interestingly, I can't get a route on my iBook for `traceroute 192.168.1.1` (it just hangs).

What have I done wrongly? Did I screw up my netmask, genmask? This is becoming increasingly frustrating, especially since all the documentation I've found says little more than to enable ip_forward in /proc; maybe I should try the universal answer... `echo 42 > /proc/sys/net/ipv4/ip_forward`

Seriously though, what's going on?

EDIT In case there was some kind of problem with my router, I just connected my gateway directly to PPPoE. I can browse the internet just fine (once I `route` chagned the default GW from 192.168.0.1 to my PPPoE IP address). I also enabled MASQUERADE in adsl-setup, but alas my iBook still can't do anything useful.

Last edited by michaelsanford; 04-13-2005 at 03:12 PM.
 
  


Reply


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
Gateway / DHCP Server problem on Slackware captain_bogus Linux - Networking 11 11-25-2008 01:28 PM
Firewall Security / Gateway Routing colabus Linux - Security 3 09-09-2005 06:40 PM
routing problem with dhcp and localhost drowstar Linux - Networking 0 01-03-2005 08:23 AM
dhcp ipmasq routing problem? ravenst1 Linux - Networking 0 08-27-2004 07:04 AM
pppoe gateway routing problems jvannucci Linux - Networking 2 06-26-2003 06:40 PM

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

All times are GMT -5. The time now is 10:26 AM.

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