Blog

2009/03/13

DHCP relay

It is not that I did not do anything since the last entry. I have been looking and trying every evening. I first thought that I should/could solve the problem with the DHCP by my firewall. This was not the case. On the internet they spoke about a DHCP relay. I figured out that I needed it on my router. I installed it. OpenWRT did not create a startup script. I created it myself but still it was not working. Perhaps it was the version.

#!/bin/sh
# dhcrelay startup

### Find the IP Address for a server.
getIP() {
  IP=`ping -c 1 $1 2>&1 | grep -E '^PING' | sed -re 's/^[^(]*.([^)]*).*/\1/'`
  if [ -z "$IP" ]; then IP="127.0.0.1"; fi
  echo $IP
}

DMZ=$(nvram get dmz_ifname)
FREE=$(nvram get free_ifname)
LAN=$(nvram get lan_ifname)
VOIP=$(nvram get voip_ifname)

DHCP=`getIP dhcp.debooy.eu`

dhcrelay -a -i $DMZ -i $FREE -i $LAN -i $VOIP $DHCP

Then I had an idea. I changed my firewall. I opened port 67 and 68 and put a logging on this rule. This for the INPUT and FOREWARD for the LAN and DMZ plus a logging on the OUTPUT. Now I saw the traffic. dhcrelay was working fine but it tried to get a reply from my VOIP network. A quick look to the script made me see the solution. I had to put the DMZ as last parameter.

dhcrelay -a -i $VOIP -i $LAN -i $FREE -i $DMZ $DHCP

I changed the script and restarted dhcrelay. A ipconfig /release followed by a ipconfig /renew resulted in an IP address from the DHCP server in my DMZ.

Beside this I also changed the configuration for both DHCP and DNS. To be honest DHCP did not really run until today. It was in the process list but I could not find an entry in the log files. For DNS I found entries including the error that the working directory was read only.
For DHCP I had to remove the trailing . in the option domain-name. Now there was an entry.
For DNS it was also simple. For the working directory I changed the directory value like the one in the original named.conf. At the same time I added 2 parameters that were in the original one.

A last point. When I stopped my old DNS server the old Squid did not function any more on the server. There must be a link between Squid and DNS. When I find it I am sure that the new Squid will function too. Another thing that is not working yet is the update of the DNS by the DHCP server. I hope to find this soon.