# DHCP and wpad

## beren43

I configure the DHCP server for the wpad. In the dhcp.conf added 

option  wpad code 252  = text;

subnet {....

option wpad "http:// 172.18.01/proxy.pac" }

But if the internet expoler to automatically set the parameters, but does not load the page. If you set a script http:// 172.18.01/proxy.pac, everything works. What could be the problem ?

----------

## khayyam

 *beren43 wrote:*   

> option wpad "http:// 172.18.01/proxy.pac" }
> 
> But if the internet expoler to automatically set the parameters, but does not load the page. If you set a script http:// 172.18.01/proxy.pac, everything works. What could be the problem ?

 

beren43 ... firstly, that is not an ip address, and there is a space in the URI. Secondly, does the httpd serving the proxy.pac know that what sort of mimetype it is.

```
AddType application/x-ns-proxy-autoconfig .pac
```

best ... khay

----------

## Ant P.

 *khayyam wrote:*   

> beren43 ... firstly, that is not an ip address

 

Not to invalidate the rest of what you said, but that's a valid notation most software recognises, even if it is a bit strange (and obviously a lucky accident it works at all here).

```
 ~ $ ping 127.1

PING 127.1 (127.0.0.1) 56(84) bytes of data.

64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.022 ms

 ~ $ ping 0x7f000001

PING 0x7f000001 (127.0.0.1) 56(84) bytes of data.

64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.021 ms

```

----------

## khayyam

 *Ant P. wrote:*   

>  *khayyam wrote:*   beren43 ... firstly, that is not an ip address 
> 
> Not to invalidate the rest of what you said, but that's a valid notation most software recognises, even if it is a bit strange (and obviously a lucky accident it works at all here).

 

Ant ... ok, its an ip address, but if you do a ping on your lan it'll take time to return, dhcp probably has a timeout, and so takes that as host unreachable.

```
# time /bin/ping -c 1 192.168.2.254 1>/dev/null

/bin/ping -c 1 192.168.2.254 1>/dev/null  0.00s user 0.00s system 0% cpu 0.004 total

# time /bin/ping -c 1 192.168.2.253 1>/dev/null

/bin/ping -c 1 192.168.2.253 1>/dev/null  0.00s user 0.00s system 0% cpu 0.008 total

# time /bin/ping -c 1 192.168.254 1>/dev/null

/bin/ping -c 1 192.168.254 1>/dev/null  0.00s user 0.00s system 0% cpu 10.003 total
```

Only the first of those addresses is reachable ... but of the two unreachable address the '192.168.254' took significantly longer. I can't test this with 192.168.0.254 obviously, but if this were reachable I'm fairly sure this would also take more time to execute.

best ... khay

----------

## beren43

 *khayyam wrote:*   

>  *beren43 wrote:*   option wpad "http:// 172.18.01/proxy.pac" }
> 
> But if the internet expoler to automatically set the parameters, but does not load the page. If you set a script http:// 172.18.01/proxy.pac, everything works. What could be the problem ? 
> 
> beren43 ... firstly, that is not an ip address, and there is a space in the URI. Secondly, does the httpd serving the proxy.pac know that what sort of mimetype it is.
> ...

 

Update: nginx, squid , dhcp server are located on the same physical server (172.18.0.1)

In nginx.conf 

```
server {

listen 172.18.0.1 ;

root /var/www/loaclhost/htdocs};

```

That is, I add

```
server {

listen 172.18.0.1 ;

root /var/www/loaclhost/htdocs};

AddType application/x-ns-proxy-autoconfig proxy.pac;

```

Correctly ?

----------

## khayyam

 *beren43 wrote:*   

> 
> 
> ```
> server {
> 
> ...

 

beren43 ... I'm not familiar with nginx, the 'AddType' directive is for apache. On a search I see nginx.conf should have an 'include mime.types' so it seems the following would be the nginx method:

```
include mime.types;

types {

   application/x-ns-proxy-autoconfig .pac 

}
```

best ... khay

----------

## beren43

I added in /etc/nginx/mime.types

```
types {

   application/x-ns-proxy-autoconfig .pac

}
```

It didn't help. The idea still there ?

----------

## khayyam

 *beren43 wrote:*   

> It didn't help. The idea still there ?

 

beren43 ... what you you using as dhcpd? In the above you'd stated "dhcp.conf", that is incorrect as net-misc/dhcp uses /etc/dhcp/dhcpd.conf (as I remember). From the syntax I'm inclined to think you are using net-misc/dhcp and so the following is the correct entry:

```
option local-pac-server code 252 = text;

option local-pac-server "http://172.18.01:80/proxy.pac";
```

Also, I don't know about nginx but with apache you need to supply a "ServerName" directive, and this is what apache expects to be the FQDN of the requested URI. So, dependent on how you've configured nginx, hosts/DNS, you may need to use the FQDN rather than the ip address.

best ... khay

----------

