Ralph Asset Management System - User Group

How to use and debug dhcp module

I’m trying to use dhcp script to generate dhpcd configuration and I’m stucked at err that I can’t fix.

[root@plinfs1517 dhcp_agent]# ./dhcp_agent.py -H 10.0.99.9 -k xxxxxxxxxxxxxxxxxxxxx -m networks -p http -d "BBN Inno Lab" -v
[2020-03-11 15:45:57.212] INFO     dhcp_agent.py:354  Sending request to http://10.0.99.9/dhcp/networks/?dc=BBN+Inno+Lab
[2020-03-11 15:45:57.212] INFO     dhcp_agent.py:330  Using If-Modified-Since with value Wed, 11 Mar 2020 13:44:35 GMT for url http://10.0.99.9/dhcp/networks/?dc=BBN+Inno+Lab
[2020-03-11 15:45:57.247] INFO     dhcp_agent.py:374  Storing Last-Modified for url http://10.0.99.9/dhcp/networks/?dc=BBN+Inno+Lab with value Wed, 11 Mar 2020 14:45:12 GMT
# DHCP Networks config generated by Ralph last modified at March 11, 2020, 2:45 p.m.

shared-network "SWITCH-MGMT" {
    subnet 10.0.99.0 netmask 255.255.255.0 {
        option routers 10.0.99.1;
        option domain-name "yyyyyyyyyyyyy";

        deny unknown-clients;
    }
}
# End of autogenerated config
[2020-03-11 15:45:57.247] INFO     dhcp_agent.py:424  Configuration written to stdout
[2020-03-11 15:45:57.247] INFO     dhcp_agent.py:336  Last modified not found in cache for url http://10.0.99.9/dhcp/sync/
[2020-03-11 15:45:57.268] ERROR    dhcp_agent.py:401  Could not send confirmation to Ralph. Server returned 404 status code with message: DHCP server doesn't exist.
[2020-03-11 15:45:57.269] INFO     dhcp_agent.py:203  Removing lock
[root@plinfs1517 dhcp_agent]#
[root@plinfs1517 dhcp_agent]# ./dhcp_agent.py -H 10.0.99.9 -k xxxxxxxxxxxxxxx-m networks -p http -d "BBN Inno Lab" -v 
[2020-03-11 15:51:15.241] INFO     dhcp_agent.py:354  Sending request to http://10.0.99.9/dhcp/networks/?dc=BBN+Inno+Lab
[2020-03-11 15:51:15.242] INFO     dhcp_agent.py:330  Using If-Modified-Since with value Wed, 11 Mar 2020 14:45:12 GMT for url http://10.0.99.9/dhcp/networks/?dc=BBN+Inno+Lab
[2020-03-11 15:51:15.271] INFO     dhcp_agent.py:366  Server return status 304 NOT MODIFIED. Nothing to do.
[2020-03-11 15:51:15.271] INFO     dhcp_agent.py:336  Last modified not found in cache for url http://10.0.99.9/dhcp/sync/
[2020-03-11 15:51:15.290] ERROR    dhcp_agent.py:401  Could not send confirmation to Ralph. Server returned 404 status code with message: DHCP server doesn't exist.
[2020-03-11 15:51:15.290] INFO     dhcp_agent.py:203  Removing lock
[root@plinfs1517 dhcp_agent]#

Obviously dhcp server is created where is supposed (I think) to be.

Ralph logs shows only this:
==> gunicorn.access.log <==
172.19.0.3 - - [11/Mar/2020:14:51:15 +0000] "GET /dhcp/networks/?dc=BBN+Inno+Lab HTTP/1.0" 304 0 "-" "Python-urllib/2.7"
172.19.0.3 - - [11/Mar/2020:14:51:15 +0000] "GET /dhcp/sync/ HTTP/1.0" 404 26 "-" "Python-urllib/2.7"
^C
root@8850dcdd94b7:/var/log/ralph#

Which is not helpful at all. :frowning:

Is there any documentation for this script or the way to enable debug in Ralph so I could understand what is happening under the hood and fix it (or report bug)?

Before running DHCP script, you need to add DHCP Server(with its IP address!), and “Network environment” to the Ralph.

Did you seee something here https://ralph-demo.allegro.tech/dhcp/dhcpserver/ ?

Then, after generating config file, dhcp script sends “heart-beat” back to Ralph, you can check last-modified column.

Hi Marcin.
Thank you for your response.

As I said before (you must overlook that) dhcp server is created. Both o/s daemon (running at 10.0.99.9 host) and ralph entry (ip 10.0.99.9 and network environment matching NE in console request) are setup.
obraz

Obviously something doesn’t match up but since I can’t debug it I don’t know what to fix.

Typical setup is to have 2 hosts

[Ralph DHCP Client] (IP address)-----------> [RALPH WWW] (IP address)

DHCP Agents does 2 jobs:

It seems, like your second job didn’t finish successfully. Let’s see why.

Problem is on the Ralph WWW server side here: https://github.com/allegro/ralph/blob/77c04541a4b9be71a73dd8b79fad6f148034afdb/src/ralph/dhcp/views.py which didn’t recognize client IP address.

It relies on the internal HTTP IP address resolution. If you happen to have both client and server on the same host, the client might be recognized as “127.0.0.1”. Try to change “DHCP IP address” to 127.0.0.1 or other internal IP to check if it works.

You might also search in Ralph logs, for line Sync request DHCP server with IP (DHCP Server IP))
to see what’s incoming IP address.

Hello.
I did some digging + reading and… got nothing of the value :frowning:

  1. I’m unable to find any log entry with phrase “Sync” in /var/log/*/* and container logs which leads me to belive that loger verbosity might be reduced or logs that u mentioned are stored in some other location.
  2. Ralph (that we got from the other team) is installed in docker containers (172.20.0.0 network)
  • ralph process (containerA) listen at 0.0.0.0:8000 and it’s fully accessible via 127.0.0.1:8000
  • nginx process (containerB) redirect 80->8000 and expose itself on parent node @ :80
  • parent node running all dockers and dhcp_agent.py (10.0.99.9) is able to reach ralph (among the others ways) via 127.0.0.1:80. Also for testing purposes I established local redirection 8000->80 so 127.0.0.1:8000 works as well.
  • dhcp server IP in ralph is set to 127.0.0.1 atm

I’m getting required records with dhcp_agent.py -v -H 127.0.0.1:8000... but sync part is failing every single time with any ip:port combination.

Since I’m unable to find any Sync request DHCP... log entries anywhere I can’t confirm for certain that client is being recognized with proper, matching ip.

Any advices Marcin ?

Hi Marcin.
Any update please?