View previous topic :: View next topic |
Author |
Message |
jhoos n00b
Joined: 30 May 2004 Posts: 43
|
Posted: Sun Dec 11, 2005 2:43 pm Post subject: DHCP routing |
|
|
Hi,
i´ve got a problem connecting a dhcp only device via my gentoo box to my network at home. I hope someone can give me a hint on what to do.
This is my physical setup: The device is connected to eth1 on my gentoo system, which is connected via eth0 to a DSL Router with DHCP- and DNS-Server.
Though both eth0 and eth1 are up and running the device doesn´t find a dhcp server (message: no link). So what do i have to do, that my gentoo systems forwards the DHCP requests over eth0 to my router?
Thanks
Here´s my ifconfig
Quote: |
eth0 Link encap:Ethernet HWaddr 00:01:29:F3:A4:14
inet addr:192.168.178.25 Bcast:192.168.178.255 Mask:255.255.255.0
inet6 addr: fe80::201:29ff:fef3:a414/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1419 errors:0 dropped:0 overruns:0 frame:0
TX packets:1502 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:219217 (214.0 Kb) TX bytes:952139 (929.8 Kb)
eth1 Link encap:Ethernet HWaddr 00:01:29:F3:A4:13
inet addr:192.168.178.21 Bcast:192.168.178.255 Mask:255.255.255.0
inet6 addr: fe80::201:29ff:fef3:a413/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:44 errors:0 dropped:0 overruns:0 frame:0
TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:104552 (102.1 Kb) TX bytes:104552 (102.1 Kb)
|
Here´s my iptables (all default):
Quote: |
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
|
Here´s my route (all default)
Quote: |
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.178.0 * 255.255.255.0 U 0 0 0 eth0
192.168.178.0 * 255.255.255.0 U 0 0 0 eth1
loopback localhost 255.0.0.0 UG 0 0 0 lo
default fritz.fonwlan.b 0.0.0.0 UG 0 0 0 eth0
default fritz.fonwlan.b 0.0.0.0 UG 0 0 0 eth1
|
|
|
Back to top |
|
|
Blood Fluke Apprentice
Joined: 15 Sep 2005 Posts: 224
|
Posted: Sun Dec 11, 2005 4:15 pm Post subject: |
|
|
First off, DHCP is not routable. That isn't the issue here, however, as both sides are on the same network.
Secondly, you really shouldn't give one host two IP addresses on the same network. What you probably think you want to do is actually bridging.
What you probably should be doing is putting one interface on a second network and running a second DHCP server. |
|
Back to top |
|
|
nielchiano Veteran
Joined: 11 Nov 2003 Posts: 1287 Location: 50N 3E
|
Posted: Sun Dec 11, 2005 4:19 pm Post subject: |
|
|
Blood Fluke wrote: | DHCP is not routable. |
True, but it is relay-able... you can forward a request. but I doubt it would work, since it would mess up the routing table on the dual-card machine.
The solution with the least trouble would be to make the dual-card machine a bridge; that way you don't have to worry about routing. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54830 Location: 56N 3W
|
Posted: Sun Dec 11, 2005 4:47 pm Post subject: |
|
|
jhoos,
Your kernel is confused.
You may not normally have two ethernet interfaces in the same subnet, as you do at the moment. Certainly you cannot do this with Gentoos standard networking scripts. You need a special script to set up your eth1 and set packet forwarding. This is a good place to start.
Code: | #!/bin/bash
#
# ipaqnet Control script for iPAQ USBNet connection
#
# Author: Michel Stempin
# Creation: 11/08/2002
# additional comments and minor tweaks
# Roy Bamford 6 Dec 2003
PC_ADDR=192.168.100.201
IPAQ_ADDR=192.168.100.202
IPAQ_NET=192.168.100.0/24
# WARNING:usb0 is hard coded in some places
UPLINK_IF=usb0
start() {
# load the usb networking module
/sbin/modprobe usbnet
# bring up the PC end of the link with IP addr PC_ADDR
# exit if it fails for some reason
/sbin/ifconfig usb0 inet $PC_ADDR up
if [ $? -ne 0 ]; then
echo "Could not set up usb0"
echo "Is the iPaq connected and switched on?"
exit 1
fi
# set up proxy_arp for our usb interface
echo "1" >/proc/sys/net/ipv4/conf/usb0/proxy_arp
UPLINK=`/sbin/ifconfig $UPLINK_IF >/dev/null 2>&1`
# exit if it fails for some reason
if [ $? -ne 0 ]; then
echo "Could not set up proxy_arp for usb0"
exit 1
fi
# set up proxy_arp for eth0, so this better be our
# internet connection
echo "1" >/proc/sys/net/ipv4/conf/eth0/proxy_arp
# turn on IP forwarding
echo "1" >/proc/sys/net/ipv4/ip_forward
# delete the unwanted route via usb0
# its wrong anyway
/sbin/route del -net $IPAQ_NET dev usb0
# add the route we really want
/sbin/route add $IPAQ_ADDR dev usb0
}
stop() {
/sbin/ifconfig usb0 down
# rmmod -r usbnet
}
case "$1" in
start|add)
start
;;
stop|remove)
stop
;;
*)
echo $"Usage: $0 {start|stop|add|remove}"
exit 1
esac |
You will need to edit it some to do what you want, with your particular IP addresses but the comments should help there.
I use it you connect my iPaq to the internet via my main PC. Your kernel needs to support packet forwarding too. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
daeghrefn Tux's lil' helper
Joined: 02 Jan 2005 Posts: 112
|
Posted: Sun Dec 11, 2005 6:19 pm Post subject: |
|
|
You have pretty much two choices. The easiest solution is to create a bridge between eth0 and eth1. This will allow all traffic, including DHCP broadcasts to reach the device on eth1. The second option is to set up routing, via IPtables, and put your auxilliary device on its own subnet. Since DHCP is not routable, as mentioned before, you would then have to emerge dhcp and configure dhcrelay (man dhcrelay) to forward DHCP requests and acknowledgements back and fourth between the subnets.
I have a setup similar to that. I have a router which has a wireless card set up as a wireless access point using hostapd. I also have a nic card plugged into the wired segment. The DHCP server is on the wired subnet. The router has dhcrelay set up and forwards DHCP requests back and fourth between the two subnets. I doubt you need anything that complicated. |
|
Back to top |
|
|
Mark Clegg Apprentice
Joined: 05 Jan 2004 Posts: 270 Location: ZZ9 Plural Z Alpha
|
Posted: Sun Dec 11, 2005 7:30 pm Post subject: |
|
|
Assuming that eth0 and eth1 are on separate networks, and you re-configure them to be on separate subnets as per NeddySeagoon's earlier post, your options could be limited by your DSL router.
If your DSL router supports multiple DHCP scopes, you'll be able to get away with running dhrelay, otherwise you'll need a complete DHCP server setup, and also possibly a DNS server with dynamic updates enabled if you want to be able to name-resolve the dhcp-only device from other nodes.
If on the other hand you really do want all the devices on the same subnet, why can't you plug the dhcp-only device into a spare port on the router instead of the gentoo box. |
|
Back to top |
|
|
jhoos n00b
Joined: 30 May 2004 Posts: 43
|
Posted: Sat Dec 17, 2005 9:54 pm Post subject: |
|
|
I just wanted to thank you all for your replies. I´ve set up a dhcp server and it works fine. Now i just need to get NAT to work. Thanks. |
|
Back to top |
|
|
|