OpenWrt Forum Archive

Topic: automatic proxy config with dnsmasq

The content of this topic has been archived on 12 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I've been strugging with this and I hope someone can shed some light on this.

I want to auto-configure a proxy on my network.  I am running

# cat /etc/openwrt_release
DISTRIB_ID="OpenWrt"
DISTRIB_RELEASE="12.09"
DISTRIB_REVISION="r36088"
DISTRIB_CODENAME="attitude_adjustment"
DISTRIB_TARGET="ar71xx/generic"
DISTRIB_DESCRIPTION="OpenWrt Attitude Adjustment 12.09"

I have squid running and configured; I can connect to it manually.  I want browsers to auto-configure to use the proxy.

To that end, I've read the docs and set up a wpad.dat at http://wpad.seiner.lan/wpad.dat

That file contains:

function FindProxyForURL(url, host)
{
   if (isInNet(host, "192.168.0.0", "255.255.0.0")) {
      return "DIRECT";
   } else {
      if (shExpMatch(url, "http:*"))
         return "PROXY 192.168.128.21:3128" ;
      if (shExpMatch(url, "https:*"))
         return "PROXY 192.168.128.21:3128" ;
      if (shExpMatch(url, "ftp:*"))
         return "PROXY 192.168.128.21:3128" ;
      return "DIRECT";
   }
}

and my /etc/config/dhcp:

config dnsmasq
    option domainneeded '1'
    option boguspriv '1'
    option localise_queries '1'
    option rebind_protection '1'
    option rebind_localhost '1'
    option local '/lan/'
    option expandhosts '1'
    option authoritative '1'
    option readethers '1'
    option leasefile '/tmp/dhcp.leases'
    option resolvfile '/tmp/resolv.conf.auto'
    option domain 'seiner.lan'
    list server '208.67.222.222'
    list server '208.67.220.220'
    list dhcp-option '252,http://wpad.seiner.lan/wpad.dat'

....

config domain
    option ip '192.168.128.21'
    option name 'wpad'

so all this should work according to the documentation I've read.  But I am running into 2 issues, both Luci related:

1.  Luci crashes when I click on the DHCP and DNS tab under Network

/usr/lib/lua/luci/dispatcher.lua:448: Failed to execute cbi dispatcher target for entry '/admin/network/dhcp'.
The called action terminated with an exception:
/usr/lib/lua/luci/cbi.lua:334: Unable to read UCI data: dhcp
stack traceback:
    [C]: in function 'assert'
    /usr/lib/lua/luci/dispatcher.lua:448: in function 'dispatch'
    /usr/lib/lua/luci/dispatcher.lua:195: in function </usr/lib/lua/luci/dispatcher.lua:194>

and
2.  there is no corresponding

dhcp_option=252,http://wpad.seiner.lan/wpad.dat

in /tmp/etc/ndnsmasq.conf

OK, so I set up a manual dnsmasq.conf that includes the proxy config:

conf-file=/etc/dnsmasq.conf
dhcp-authoritative
domain-needed
localise-queries
read-ethers
bogus-priv
expand-hosts
domain=seiner.lan
server=/lan/
server=208.67.222.222
server=208.67.220.220
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.auto
stop-dns-rebind
rebind-localhost-ok
dhcp-option=252,http://wpad.seiner.lan/wpad.dat

However, tcpdump never shows dnsmasq sending it out:

02:33:11.718657 IP (tos 0x0, ttl 64, id 17254, offset 0, flags [none], proto UDP (17), length 343)
    0.0.0.0.bootpc > 255.255.255.255.bootps: [udp sum ok] BOOTP/DHCP, Request from c4:43:8f:c9:cc:69 (oui Unknown), length 315, xid 0x33981c59, Flags [none] (0x0000)
      Client-Ethernet-Address c4:43:8f:c9:cc:69 (oui Unknown)
      Vendor-rfc1048 Extensions
        Magic Cookie 0x63825363
        DHCP-Message Option 53, length 1: Request
        Client-ID Option 61, length 7: ether c4:43:8f:c9:cc:69
        Requested-IP Option 50, length 4: 192.168.128.205
        MSZ Option 57, length 2: 1500
        Vendor-Class Option 60, length 12: "dhcpcd-5.5.6"
        Hostname Option 12, length 24: "android-c872a60161b5d332"
        Parameter-Request Option 55, length 10: 
          Subnet-Mask, Static-Route, Default-Gateway, Domain-Name-Server
          Domain-Name, MTU, BR, Lease-Time
          RN, RB
02:33:11.722999 IP (tos 0x0, ttl 64, id 23469, offset 0, flags [none], proto UDP (17), length 332)
    192.168.128.21.bootps > 192.168.128.205.bootpc: [bad udp cksum 0x837d -> 0x94c6!] BOOTP/DHCP, Reply, length 304, xid 0x33981c59, Flags [none] (0x0000)
      Your-IP 192.168.128.205
      Server-IP 192.168.128.21
      Client-Ethernet-Address c4:43:8f:c9:cc:69 (oui Unknown)
      Vendor-rfc1048 Extensions
        Magic Cookie 0x63825363
        DHCP-Message Option 53, length 1: ACK
        Server-ID Option 54, length 4: 192.168.128.21
        Lease-Time Option 51, length 4: 43200
        RN Option 58, length 4: 21600
        RB Option 59, length 4: 37800
        Subnet-Mask Option 1, length 4: 255.255.255.0
        BR Option 28, length 4: 192.168.128.255
        Default-Gateway Option 3, length 4: 192.168.128.21
        Domain-Name-Server Option 6, length 4: 192.168.128.21
        Domain-Name Option 15, length 10: "seiner.lan"

What in the world is going on?

I think it should be _ not - (i.e. dhcp_option)

The discussion might have continued from here.