How to - DHCP Relay and Server on same machine (FreeBSD)

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

How to - DHCP Relay and Server on same machine (FreeBSD)

test24
Hello!

I need to use DHCP Relay and DHCP Server  on same machine, but while compile and try to use with lot of options - no positive result.

But how to compile with right options

Setup:
Freebsd 9.x
CLIENTS <---> [ Multi igb0,1,2,3,4, em0,1, multiple vlans] (relay agent) <---> DHCP Server ]

The relay agent *runs on ALL interfaces that faces the client and DHCP server runs and listen other port such as 77 and

rc.conf

dhcpd_enable="YES"
dhcpd_flags="-p 77"
dhcpd_ifaces="igb1"

dhcrelay_enable="YES"
dhcrelay_flags="-a -d -D"
dhcrelay_servers="10.10.10.1"  # DHCPD IP on igb1 iface
dhcrelay_ifaces=""

dhcpd.conf

local-address 10.10.10.1;

stash-agent-options true;
# for debug
allow unknown-clients;

if exists agent.circuit-id

{
log (
info, concat( " Lease for ", binary-to-ascii (10, 8, ".", leased-address),
 " Swith port: ", binary-to-ascii (10, 8, ".", option agent.circuit-id),
 " Switch MAC: ", binary-to-ascii (16, 8, ":", suffix ( option agent.remote-id, 6)),
 " Switch IP: ", binary-to-ascii(10, 8, ".", packet(24, 4)),
 " VLAN: ", binary-to-ascii (10, 16, "", substring( option agent.circuit-id, 2, 2)),
 " MAC on the port: ", binary-to-ascii (16, 8, ":", substring(hardware, 1, 6))
)
);


With classic dhcp server ONLY - all work ok

When dhcp relay and server starts both on same machine - no errors due to misconfiguration or
already socket listen - at that point all ok

I see incoming packets from clients on dhcp relay side but not see packets on dhcp server side
Where is mistake and how to ./configure and make dhcp relay and server with right options ?

Thanks

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: How to - DHCP Relay and Server on same machine (FreeBSD)

Simon Hobson
test24 <[hidden email]> wrote:

> I need to use DHCP Relay and DHCP Server  on same machine, but while compile and try to use with lot of options - no positive result.
>
> But how to compile with right options
>
> Setup:
> Freebsd 9.x
> CLIENTS <---> [ Multi igb0,1,2,3,4, em0,1, multiple vlans] (relay agent) <---> DHCP Server ]
>
> The relay agent *runs on ALL interfaces that faces the client and DHCP server runs and listen other port such as 77 and
>
> rc.conf
>
> dhcpd_enable="YES"
> dhcpd_flags="-p 77"
> dhcpd_ifaces="igb1"
>
> dhcrelay_enable="YES"
> dhcrelay_flags="-a -d -D"
> dhcrelay_servers="10.10.10.1"  # DHCPD IP on igb1 iface
> dhcrelay_ifaces=""

Is the relay agent configured to send out to, and listen for replies from, the alternate server port ? I don't know enough about the relay agent to know if this configuration is possible.

If it's not configured to do that, then the relay agent may try and send the packet - but it'll find itself listening on the port. I suspect you might not see the packets on the wire since they would be routed internally as local to the host.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: How to - DHCP Relay and Server on same machine (FreeBSD)

Roberto Innocente
In reply to this post by test24

client
listen on 68 sends to port 67 --->
                       relay listen on 67 forwards on 67
                                     --> server listen on 67 replies to
68 or 67 (if its a relay)

cant work unless you change ports used




On 2015-06-17 14:24, test24 wrote:

> Hello!
>
> I need to use DHCP Relay and DHCP Server on same machine, but while
> compile and try to use with lot of options - no positive result.
>
> But how to compile with right options
>
> Setup:
> Freebsd 9.x
> CLIENTS <---> [ Multi igb0,1,2,3,4, em0,1, multiple vlans] (relay
> agent) <---> DHCP Server ]
>
>  The relay agent *runs on ALL interfaces that faces the client and
> DHCP server runs and listen other port such as 77 and
>
> rc.conf
>
> dhcpd_enable="YES"
> dhcpd_flags="-p 77"
> dhcpd_ifaces="igb1"
>
> dhcrelay_enable="YES"
> dhcrelay_flags="-a -d -D"
> dhcrelay_servers="10.10.10.1" # DHCPD IP on igb1 iface
> dhcrelay_ifaces=""
>
> dhcpd.conf
>
> local-address 10.10.10.1;
>
> stash-agent-options true;
> # for debug
> allow unknown-clients;
>
> if exists agent.circuit-id
>
> {
> log (
> info, concat( " Lease for ", binary-to-ascii (10, 8, ".",
> leased-address),
>  " Swith port: ", binary-to-ascii (10, 8, ".", option
> agent.circuit-id),
>  " Switch MAC: ", binary-to-ascii (16, 8, ":", suffix ( option
> agent.remote-id, 6)),
>  " Switch IP: ", binary-to-ascii(10, 8, ".", packet(24, 4)),
>  " VLAN: ", binary-to-ascii (10, 16, "", substring( option
> agent.circuit-id, 2, 2)),
>  " MAC on the port: ", binary-to-ascii (16, 8, ":",
> substring(hardware, 1, 6))
> )
> );
>
> With classic dhcp server ONLY - all work ok
>
> When dhcp relay and server starts both on same machine - no errors due
> to misconfiguration or
> already socket listen - at that point all ok
>
> I see incoming packets from clients on dhcp relay side but not see
> packets on dhcp server side
> Where is mistake and how to ./configure and make dhcp relay and server
> with right options ?
>
> Thanks
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users

--
Roberto Innocente - SISSA
[hidden email] - +39 40 3787541
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re[2]: How to - DHCP Relay and Server on same machine (FreeBSD)

test24



Среда, 17 июня 2015, 16:26 +02:00 от Roberto Innocente <[hidden email]>:

client
listen on 68 sends to port 67 --->
                       relay listen on 67 forwards on 67
                                     --> server listen on 67 replies to
68 or 67 (if its a relay)

cant work unless you change ports used

man dhcpd says:

       -p port
              The  udp  port number on which dhcpd should listen.  If unspeci-
              fied dhcpd uses the default port of 67.  This is  mostly  useful
              for debugging purposes.

       -s address
              Specify  an  address  or  host  name  to which dhcpd should send
              replies rather than  the  broadcast  address  (255.255.255.255).
              This option is only supported in IPv4.


than dhcpd  listen 10.10.10.1:77

man dhcp relay says:

-p PORT
              Listen  and  transmit  on  port PORT.  This is mostly useful for
              debugging purposes.  Default is port  67  for  DHCPv4/BOOTP


dhcpd and relay cannot work on same socket on same machine, than i need to
say dhcpd to listen another port such as 77. and dchp relay forward all requests from 67 port to 77 port dhcpd


and shema is next:

clients ip*:67/68 port <-> all ifaces *:68/68 dhcp relay send/receive 77port <-> 10.10.10.1:77 port dhcpd

But this shema do not work on relay <-> dhcpd side - no any info in logs and any packets by dumping 10.10.10.1:77








On 2015-06-17 14:24, test24 wrote:
> Hello!
>
> I need to use DHCP Relay and DHCP Server on same machine, but while
> compile and try to use with lot of options - no positive result.
>
> But how to compile with right options
>
> Setup:
> Freebsd 9.x
> CLIENTS <---> [ Multi igb0,1,2,3,4, em0,1, multiple vlans] (relay
> agent) <---> DHCP Server ]
>
> The relay agent *runs on ALL interfaces that faces the client and
> DHCP server runs and listen other port such as 77 and
>
> rc.conf
>
> dhcpd_enable="YES"
> dhcpd_flags="-p 77"
> dhcpd_ifaces="igb1"
>
> dhcrelay_enable="YES"
> dhcrelay_flags="-a -d -D"
> dhcrelay_servers="10.10.10.1" # DHCPD IP on igb1 iface
> dhcrelay_ifaces=""
>
> dhcpd.conf
>
> local-address 10.10.10.1;
>
> stash-agent-options true;
> # for debug
> allow unknown-clients;
>
> if exists agent.circuit-id
>
> {
> log (
> info, concat( " Lease for ", binary-to-ascii (10, 8, ".",
> leased-address),
> " Swith port: ", binary-to-ascii (10, 8, ".", option
> agent.circuit-id),
> " Switch MAC: ", binary-to-ascii (16, 8, ":", suffix ( option
> agent.remote-id, 6)),
> " Switch IP: ", binary-to-ascii(10, 8, ".", packet(24, 4)),
> " VLAN: ", binary-to-ascii (10, 16, "", substring( option
> agent.circuit-id, 2, 2)),
> " MAC on the port: ", binary-to-ascii (16, 8, ":",
> substring(hardware, 1, 6))
> )
> );
>
> With classic dhcp server ONLY - all work ok
>
> When dhcp relay and server starts both on same machine - no errors due
> to misconfiguration or
> already socket listen - at that point all ok
>
> I see incoming packets from clients on dhcp relay side but not see
> packets on dhcp server side
> Where is mistake and how to ./configure and make dhcp relay and server
> with right options ?
>
> Thanks
>
> _______________________________________________
> dhcp-users mailing list
> dhcp-users@...
> https://lists.isc.org/mailman/listinfo/dhcp-users

--
Roberto Innocente - SISSA
inno@... - +39 40 3787541


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: How to - DHCP Relay and Server on same machine (FreeBSD)

Simon Hobson
test24 <[hidden email]> wrote:

> man dhcp relay says:
>
> -p PORT
>               Listen  and  transmit  on  port PORT.  This is mostly useful for
>               debugging purposes.  Default is port  67  for  DHCPv4/BOOTP

That changes the port the relay agent uses - but **NOT** the port it assumes the server is using. Checking the man page I see nothing to suggest it can talk to a server via a non-standard port - you could try "nnn.nnn.nnn.nnn:77" for server IP, but I suspect that's not implemented.

If not, I imagine it might be "relatively" simple to edit the code and hard code a different server port to use.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re[3]: How to - DHCP Relay and Server on same machine (FreeBSD)

test24
In reply to this post by test24

dhcpd and relay cannot work on same socket on same machine, than i need to
say dhcpd to listen another port such as 77. and dchp relay forward all requests from 67 port to 77 port dhcpd


and shema is next:

clients ip*:67/68 port <-> all ifaces *:68/68 dhcp relay send/receive 77port <-> 10.10.10.1:77 port dhcpd

But this shema do not work on relay <-> dhcpd side - no any info in logs and any packets by dumping 10.10.10.1:77

config is next:

dhcpd_enable="YES"
dhcpd_flags="-p 77"
dhcpd_ifaces=""

dhcrelay_enable="YES"
dhcrelay_flags="-a -d -D"                     # command option(s)
dhcrelay_servers="10.10.10.1"         # v4 dhcrelay server(s)
dhcrelay_ifaces=""

sockstat

dhcpd    dhcpd      91416 3  dgram  -> /var/run/logpriv
dhcpd    dhcpd      91416 20 udp4   *:30026               *:*
dhcpd    dhcpd      91416 21 udp6   *:56949               *:*
dhcpd    dhcpd      91416 46 udp4   10.10.10.1:77         *:*

root     dhcrelay   91426 3  dgram  -> /var/run/logpriv
root     dhcrelay   91426 20 udp4   *:55611               *:*
root     dhcrelay   91426 21 udp6   *:13530               *:*
root     dhcrelay   91426 45 udp4   *:67                  *:*


dhcpd  Sending on   Socket/fallback/fallback-net

dhcp relay  sockstat   dhcrelay listen udp4   *:67  *:*


dhcp relay log file:

Adding 9-byte relay agent option
Forwarded BOOTREQUEST for 00:11:11:09:dd:f7 to 10.10.10.1
Adding 9-byte relay agent option
Forwarded BOOTREQUEST for 2c:76:8a:dd:64:9e to 10.10.10.1
Adding 9-byte relay agent option
Forwarded BOOTREQUEST for b8:70:f4:8c:b7:0b to 10.10.10.1

and dhcpd log file is empty ..... and no reply from dhcpd



_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: How to - DHCP Relay and Server on same machine (FreeBSD)

Simon Hobson
test24 <[hidden email]> wrote:

> dhcpd and relay cannot work on same socket on same machine, than i need to
> say dhcpd to listen another port such as 77. and dchp relay forward all requests from 67 port to 77 port dhcpd
> ...

You've already said all that !

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re[5]: How to - DHCP Relay and Server on same machine (FreeBSD)

test24
In reply to this post by Roberto Innocente
Sorry for my mail client - it send from russian resource with russian incorrect text injection.

>Firstly, could you please fix your email client and get it to quote text properly !

May be it is incorrect question, but who write/rewrite/ make patches to ISC DHCP Relay code?

Generally dhcprelay - not very difficult port forward tool with dhcp's specific ports and broadcast etc. mechanisms.
I do not want use second machine, because of care for the environment named 'green technology' and I know lot
of situations when for the dhcp relay's purposes is allocated a separate machine with it wattage use.

Second reason to ask to make an different port forward option for Relay - it is a most beautiful opportunity of realization dhcp server and
relay on same machine because of higher interconnect speed (no crosslan traffic with its latency, etc.)

And better think - make the product named such as DHCPDRC (Daemon+Relay+Client) - ALL in one code cake - with flexible options for its needs.

Thanks a lot.
test24 <test24 at mail.ru> wrote: > Simon Hobson WROTE >>> test24 <test24 at mail.ru >> > wrote: >>>> > >> man dhcp relay says: >>>> >> >> -p PORT >>>> > >> Listen and transmit on port PORT. This is mostly useful for >>>> > >> debugging purposes. Default is port 67 for DHCPv4/BOOTP >>>>>> That changes the port the relay agent uses - but **NOT** the port it assumes the server is using. Checking the man page I see nothing to suggest it can talk to a server via a non-standard port - you could try "nnn.nnn.nnn.nnn:77" for server IP, but I suspect that's not implemented. >>>> If not, I imagine it might be "relatively" simple to edit the code and hard code a different server port to use. > For dhcp relay next server is written in rc.conf as the >> dhcrelay_servers="10.10.10.1" # v4 dhcrelay server(s) >> and option -P says ONLY ! one port - for clients and for next server >> This port is the same for clients and for next server You've already said that - we've seen it > In my case dhcp relay MUST listen one port (standart 67/68 for clients side) and send requests to NEXT server on OTHER port. You've already said that - it's been pointed out that it probably can't do it without editing the code. I haven't looked at the code, but I suspect there's a constant defined which is used as the destination port for packets sent to the server. Changing this is likely to do what you want. More elegantly, allowing the server to be specified as "IP:Port" (if it's not already) would be even better and would allow what you want from the command line without any editing or compiling. > It is one the SAME machine, than I can not say ! dhcpD ! listen 67 port too. And as a result - dhcpd server not see requests on 77 port because dhcp relay uses only ONE port > for clients side and for servers side. Yes, I got that first time around. Though actually it is not correct. It's not because the Relay agent only uses one port, it's because the relay agent doesn't appear to have a facility to talk to the server running on a non-standard port. > It is generally unneded if the relay and server placed on different machines, but if machine is same - it is actual needed feature... because i want to add option 82 packets > by relay and send replies on this requests by dhcpd server without using second machine. Yes, and I got that first time around as well.
<br style="overflow: auto;" dir="ltr" id="tinymce" class="mceContentBody " onload="window.parent.tinyMCE.get('compose_617_composeEditor').onLoad.dispatch();" contenteditable="true">


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: How to - DHCP Relay and Server on same machine (FreeBSD)

Simon Hobson
test24 <[hidden email]> wrote:

> May be it is incorrect question, but who write/rewrite/ make patches to ISC DHCP Relay code?

That's the beauty of FOSS (Free & Open Source Software) - anyone can. ISC will if you pay them, otherwise it's a case of find anyone with the right coding skills, download the code, and away you go.
AIUI, much of the current codebase was written under contract from a commercial sponsor.

But as I said, it might be worth downloading the source and having a look. If you find a constant in there that's used for the destination port when sending to the server, then you might only need to change that constant and compile. Adding an extra option will be somewhat more work.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Re[5]: How to - DHCP Relay and Server on same machine (FreeBSD)

glenn.satchell
In reply to this post by test24
Can you run a virtual machine on this server and have the dhcp daemon on
that? It only needs a single IP address as the relay will forward all
traffic to it.

A little more work to set up and manage, but it would still satisfy your
requirements of no more physical servers and allow you to run the standard
dhcp relay and daemon packages.

regards,
-glenn

On Thu, June 18, 2015 4:57 am, test24 wrote:

>  Sorry for my mail client - it send from russian resource with russian
> incorrect text injection.
>
>>Firstly, could you please fix your email client and get it to quote text
>> properly !
>
> May be it is incorrect question, but who write/rewrite/ make patches to
> ISC DHCP Relay code?
>
> Generally dhcprelay - not very difficult port forward tool with dhcp's
> specific ports and broadcast etc. mechanisms.
> I do not want use second machine, because of care for the environment
> named 'green technology' and I know lot
> of situations when for the dhcp relay's purposes is allocated a separate
> machine with it wattage use.
>
> Second reason to ask to make an different port forward option for Relay -
> it is a most beautiful opportunity of realization dhcp server and
> relay on same machine because of higher interconnect speed (no crosslan
> traffic with its latency, etc.)
>
> And better think - make the product named such as DHCPDRC
> (Daemon+Relay+Client) - ALL in one code cake - with flexible options for
> its needs.
>
> Thanks a lot.
>
> test24 <test24 at mail.ru> wrote:
>
>>  Simon Hobson WROTE
>>>> test24 <test24 at mail.ru
>>> > wrote:
>>>>> >
>>>  man dhcp relay says:
>>>>> >>
>>>  -p PORT
>>>>> >
>>>                Listen  and  transmit  on  port PORT.  This is mostly
>>> useful for
>>>>> >
>>>                debugging purposes.  Default is port  67  for
>>> DHCPv4/BOOTP
>>>>>>> That changes the port the relay agent uses - but **NOT** the port
>>>>>>> it assumes the server is using. Checking the man page I see nothing
>>>>>>> to suggest it can talk to a server via a non-standard port - you
>>>>>>> could try "nnn.nnn.nnn.nnn:77" for server IP, but I suspect that's
>>>>>>> not implemented.
>>>>> If not, I imagine it might be "relatively" simple to edit the code
>>>>> and hard code a different server port to use.
>
>
>> For dhcp relay next server is written in rc.conf as the
>>> dhcrelay_servers="10.10.10.1"         # v4 dhcrelay server(s)
>>> and option -P says ONLY ! one port - for clients and for next server
>>> This port is the same for clients and for next server
>
> You've already said that - we've seen it
>
>> In my case dhcp relay MUST listen one port (standart 67/68 for clients
>> side) and send requests to NEXT server on OTHER port.
>
> You've already said that - it's been pointed out that it probably can't do
> it without editing the code.
> I haven't looked at the code, but I suspect there's a constant defined
> which is used as the destination port for packets sent to the server.
> Changing this is likely to do what you want.
> More elegantly, allowing the server to be specified as "IP:Port" (if it's
> not already) would be even better and would allow what you want from the
> command line without any editing or compiling.
>
>> It is one the SAME machine, than I can not say ! dhcpD ! listen 67 port
>> too. And as a result - dhcpd server not see requests on 77 port because
>> dhcp relay uses only ONE port
>> for clients side and for servers side.
>
> Yes, I got that first time around.
> Though actually it is not correct. It's not because the Relay agent only
> uses one port, it's because the relay agent doesn't appear to have a
> facility to talk to the server running on a non-standard port.
>
>> It is generally unneded if the relay and server placed on different
>> machines, but if machine is same - it is actual needed feature...
>> because i want to add option 82 packets
>> by relay and send replies on this requests by dhcpd server without using
>> second machine.
>
> Yes, and I got that first time around as well.
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: How to - DHCP Relay and Server on same machine (FreeBSD)

Alex Bligh
In reply to this post by Simon Hobson

On 17 Jun 2015, at 21:52, Simon Hobson <[hidden email]> wrote:

> test24 <[hidden email]> wrote:
>
>> May be it is incorrect question, but who write/rewrite/ make patches to ISC DHCP Relay code?
>
> That's the beauty of FOSS (Free & Open Source Software) - anyone can. ISC will if you pay them, otherwise it's a case of find anyone with the right coding skills, download the code, and away you go.
> AIUI, much of the current codebase was written under contract from a commercial sponsor.

I looked at changing the relay ports once. It looked trivial. In the event I didn't need to do it.

--
Alex Bligh




_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users