0
  • eth0 IP: 192.168.1.100
  • Alias interface eth0:dhcp IP: 10.10.1.100

dhcpd.conf:

authoritative;
local-address 10.10.1.100;

subnet 10.10.1.0 netmask 255.255.255.0 {

    range 10.10.1.10 10.10.1.50;
    option routers 10.10.1.1;
    option domain-name-servers 8.8.8.8, 8.8.4.4;

}

Running processes:

# ps -elf | grep [d]hcp
4 S root      1876  1867  0  80   0 -  1661 poll_s 11:11 pts/2    00:00:00 dhcrelay -i eth0 10.10.1.100 -i eth0:dhcp -d
5 S dhcpd     1947     1  0  80   0 - 12121 poll_s 11:38 ?        00:00:00 /usr/sbin/dhcpd -user dhcpd -group dhcpd eth0:dhcp

I see DHCP DISCOVERs coming on eth0 and the relay agent forwards it to 10.10.1.100:

Forwarded BOOTREQUEST for <mac_address> to 10.10.1.100
Forwarded BOOTREQUEST for <mac_address> to 10.10.1.100
Forwarded BOOTREQUEST for <mac_address> to 10.10.1.100
Forwarded BOOTREQUEST for <mac_address> to 10.10.1.100

but DHCP server logs the following message:

Sep  4 11:13:47 localhost dhcpd: DHCPDISCOVER from <mac_address> via 192.168.1.1: unknown network segment
Sep  4 11:13:50 localhost dhcpd: DHCPDISCOVER from <mac_address> via 192.168.1.1: unknowk network segment
Sep  4 11:13:54 localhost dhcpd: DHCPDISCOVER from <mac_address> via 192.168.1.1: unknown network segment
Sep  4 11:13:59 localhost dhcpd: DHCPDISCOVER from <mac_address> via 192.168.1.1: unknown network segment

IP forwarding is enabled:

net.ipv4.ip_forward = 1

Basically the server must be on 192.168.1.0/24 network however it should distribute IPs from 10.10.1.0/24 range.

HTF
  • 3,148
  • 14
  • 52
  • 82
  • You don't need a relay for this. There is just one network segment and one internface -- eth0. – gtirloni Sep 05 '14 at 14:06
  • In that case do you know if DHCP server can actually lease IPs on subnet from configuration file (10.10.1.0/24) even if it's configured with different IP (192.168.1.100)? – HTF Sep 05 '14 at 15:06
  • Yes, it can. However, I hope the router you specified (10.10.1.1) is another device, right? Otherwise you need that IP on this server, just confirming. – gtirloni Sep 05 '14 at 15:08
  • Well, the problem is that DHCP server must be on 192.168.1.0/24 so router (192.168.1.1) is configured to point to 192.168.1.100 for DHCP requests - this is a temporary solution. I was wondering if I can achieve this with IPtables or something similar. These IPs are distributed for VPN clients. – HTF Sep 05 '14 at 15:33

2 Answers2

1

Assuming ISC DHCPD you do not need dhcp relay but you need shared-network in your dchpd.conf:

authoritative;
local-address 10.10.1.100;

shared-network eth0 {

    subnet 192.168.1.100 netmask 255.255.255.0 {
    }

    subnet 10.10.1.0 netmask 255.255.255.0 {

        range 10.10.1.10 10.10.1.50;
        option routers 10.10.1.1;
        option domain-name-servers 8.8.8.8, 8.8.4.4;

    }
}
Tomek
  • 3,390
  • 1
  • 16
  • 10
0

To me it looks like your DHCP relay is listening on the wrong interface. The DHCP relay has to listen receive DHCP requests by clients on the interface which is configured for the client subnet, so that it can relay that information to the DHCP server.

your dhcrelay commandline suggests you are using eth0 as receiving interface. I would try this commandline:

dhcrelay -i eth0:dhcp -d 192.168.1.100

This way you would receive DHCP requests from eth0:dhcp (10.10.1.100) and send them to the server on 192.168.1.100. And don't forget to change local-adress in dhcpd.conf.

I don't know the exact RFCs, but Wikipedia can be quite some help (Wikipedia on DHCP relaying). Also, read the fine manual: dhcrelay manual and dhcpcd.conf manual

bjoern
  • 21
  • 2