How To Configure DHCP on OpenWRT router

First uninstall pre-installed dnsmasq:

/etc/init.d/dnsmasq stop
opkg remove dnsmasq

Then install the ISC DHCP server app:

opkg install


Once that is done run:

nano /etc/dhcpd.conf

and replace the content with this:

# Show that we want to be the only DHCP server in this network:

option domain-name "";
option domain-name-servers,;
#DHCP Scope:
subnet netmask {
#DHCP range
#default gateway
option routers;

default-lease-time 691200; # 8 days
max-lease-time 864000; # 10 days

# Static assignments
host PC1 {
hardware ethernet 00:11:22:33:44:55;

host PC2 {
hardware ethernet 00:88:77:77:66:66;

Save the file and start the service

/etc/init.d/dhcpd start

To see dhcpd leases run:

more /var/dhcpd.leases

# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.2.4

lease {
  starts 4 2015/03/05 17:57:24;
  ends 4 2015/03/05 17:59:24;
  tstp 4 2015/03/05 17:59:24;
  cltt 4 2015/03/05 17:57:24;
  binding state free;
  hardware ethernet 11:22:33:55:44:33;
  client-hostname "Windows7-PC";
lease {
  starts 4 2015/03/05 18:19:06;
  ends 4 2015/03/05 18:21:06;
  tstp 4 2015/03/05 18:21:06;
  cltt 4 2015/03/05 18:19:06;
  binding state free;
  hardware ethernet 11:33:55:ee:ff:55;
  client-hostname "mobile-phone";

Job done. To install DNS follow here.

How to deploy proxy settings via DHCP

1. Install IIS and make some config changes:

  1. In IIS Manager, right-click the website or website directory for which you want to add a MIME type, and click Properties.
  2. Click the HTTP Headers tab.
  3. Click Mime Types.
  4. Click New.
  5. In the Extension box, enter the file name extension: .pac
  6. In the MIME type box, enter the MIME type description: application/x-ns-proxy-autoconfig
  7. Click OK and then restart the IIS service.
  8. then go to c:inetpubwwroot and create proxy folder

 2. create wpad.PAC file and copy it to the created proxy folder

example pac file:

function FindProxyForURL(url, host)

        // Add hostname exceptions for sites you do not want to
        // proxy e.g. internal servers

        if(shExpMatch(url,”**”)) { return “DIRECT”; }

        // if(shExpMatch(url,”**/*”)) { return “DIRECT”; }
        // End hostname exceptions

        // If you want to allow a specific IP range to go direct, use the line
        // below or remove it

        if(isInNet(host, “”, “”)) { return “DIRECT”; }

        // End network exceptions

        // Always bypass for localhost – make sure these 3 lines remain
        if (shExpMatch(host, “localhost*”) || shExpMatch(host, “*”)) { return “DIRECT”; }

        // The browser is on a specific network, so send it a specific proxy to use
        // This is useful for multi-subnet networks with multiple CensorNet servers
        // Remove if you do not need this

        // if (isInNet(host, “”, “”)) {
        //        return “PROXY”;
        // }

    // Proxy if PC is on local LAN

    if (isInNet(myIpAddress(), “”, “”))

    return “PROXY”;


    return “DIRECT”;


3. make sure you can download the wpad.pac file, – so go to your browser and type in the URL: http://IP_address/proxy/wpad.pac

4. modify DHCP

To create an option 252 entry in DHCP

  1. Click Start, point to All Programs, point to Administrative Tools, and then click DHCP.
  2. In the console tree, right-click the applicable DHCP server, click Set Predefined Options, and then click Add.
  3. In Name, type WPAD.
  4. In Code, type 252.
  5. In Data type, select String, and then click OK.
  6. In String, type http://Computer_Name:Port/wpad.dat where:
    • Computer_Name is the fully qualified domain name of the ISA Server computer.
    • Port is the port number on which automatic discovery information is published. You can specify any port number. By default, ISA Server publishes automatic discovery information on port 8080.
  7. Right-click Server options, and then click Configure options.
  8. Confirm that Option 252 is selected.