# Static IP with dnsmasq

## v1pEr

I'm running dnsmasq on my router/server now but I want to give some clients a specific IP and others an ip from a limited range.

So I configured my dnsmasq as instructed by the comments:

```
RoSe v1per # confcat /etc/dnsmasq.conf

domain-needed

interface=eth0

dhcp-range=192.168.0.200,192.168.0.250,24h

dhcp-host=00:23:54:7C:C6:0B,elise,192.169.0.10,24h

dhcp-host=00:13:D4:F0:B3:C2,sarah,192.169.0.20,24h

dhcp-option=option:ntp-server,0.0.0.0

dhcp-option=19,0           # option ip-forwarding off

dhcp-option=44,0.0.0.0     # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)

dhcp-option=45,0.0.0.0     # netbios datagram distribution server

dhcp-option=46,8           # netbios node type

dhcp-option=47             # empty netbios scope.

dhcp-option=vendor:MSFT,2,1i

log-queries

log-dhcp

```

My DHCP and DNS work just fine, except I don't get the IP I wanted to (elise) on my windows clients:

```
Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : Realtek RTL8168C(P)/8111C(P) Family PCI-E

 Gigabit Ethernet NIC (NDIS 6.20)

   Physical Address. . . . . . . . . : 00-23-54-7C-C6-0B

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

   Link-local IPv6 Address . . . . . : fe80::ec94:f3dd:5404:40bb%11(Preferred)

   IPv4 Address. . . . . . . . . . . : 192.168.0.230(Preferred)

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   Lease Obtained. . . . . . . . . . : maandag 24 augustus 2009 19:33:30

   Lease Expires . . . . . . . . . . : dinsdag 25 augustus 2009 19:33:30

   Default Gateway . . . . . . . . . : 192.168.0.1

   DHCP Server . . . . . . . . . . . : 192.168.0.1

   DHCPv6 IAID . . . . . . . . . . . : 234890068

   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-11-9F-C2-65-00-23-54-7C-C6-0B

   DNS Servers . . . . . . . . . . . : 192.168.0.1

   Primary WINS Server . . . . . . . : 192.168.0.1

   NetBIOS over Tcpip. . . . . . . . : Enabled
```

What did I do wrong?

----------

## energyman76b

dhcp-range=192.168.0.200,192.168.0.250,24h 

 dhcp-host=00:23:54:7C:C6:0B,elise,192.169.0.10,24h 

well, your range is from 200 to 250 but you try to assign 10. What happens if you change either your range or the assigned ip to something like 220?

----------

## v1pEr

I noticed too and changed it so the static ip's are in the range, but to no avail. Also according to the documentation it should work outside the range:

 *Quote:*   

> # Supply parameters for specified hosts using DHCP. There are lots
> 
> # of valid alternatives, so we will give examples of each. Note that
> 
> # IP addresses DO NOT have to be in the range given above, they just
> ...

 

----------

## energyman76b

since I don't have windows .. only a linux box which gets the right ip (the network with windows boxes is served by isc dhcp)... are you sure that the windows box gets its ip from your dnsmasq running box? What does your log say about this?

----------

## v1pEr

 *energyman76b wrote:*   

> What does your log say about this?

 Oh, sorry about forgetting to post the log, I planned to though:

```
RoSe v1per # cat /var/log/everything/current | grep dnsmasq

Aug 25 06:53:21 [dnsmasq] DHCP packet: transaction-id is 3150707045

Aug 25 06:53:21 [dnsmasq] Available DHCP range: 192.168.0.200 -- 192.168.0.250

Aug 25 06:53:21 [dnsmasq] Vendor class: MSFT 5.0

Aug 25 06:53:24 [dnsmasq] DHCPDISCOVER(eth0) 00:23:54:7c:c6:0b

Aug 25 06:53:24 [dnsmasq] DHCPOFFER(eth0) 192.168.0.230 00:23:54:7c:c6:0b

Aug 25 06:53:24 [dnsmasq] requested options: 1:netmask, 15:domain-name, 3:router, 6:dns-server,

Aug 25 06:53:24 [dnsmasq] requested options: 44:netbios-ns, 46:netbios-nodetype, 47:netbios-scope,

Aug 25 06:53:24 [dnsmasq] requested options: 31:router-discovery, 33:static-route, 121:classless-static-route,

Aug 25 06:53:24 [dnsmasq] requested options: 249, 43:vendor-encap

Aug 25 06:53:24 [dnsmasq] sent size:  1 option: 53:message-type  02

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 54:server-identifier  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 51:lease-time  00:01:51:80

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 58:T1  00:00:a8:c0

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 59:T2  00:01:27:50

Aug 25 06:53:24 [dnsmasq] sent size:  4 option:  1:netmask  ff:ff:ff:00

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 28:broadcast  c0:a8:00:ff

Aug 25 06:53:24 [dnsmasq] sent size:  4 option:  3:router  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size:  4 option:  6:dns-server  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size:  0 option: 47:netbios-scope

Aug 25 06:53:24 [dnsmasq] sent size:  1 option: 46:netbios-nodetype  08

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 44:netbios-ns  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size:  7 option: 43:vendor-encap  02:04:00:00:00:01:ff

Aug 25 06:53:24 [dnsmasq] DHCP packet: transaction-id is 3150707045

Aug 25 06:53:24 [dnsmasq] Available DHCP range: 192.168.0.200 -- 192.168.0.250

Aug 25 06:53:24 [dnsmasq] Vendor class: MSFT 5.0

Aug 25 06:53:24 [dnsmasq] DHCPREQUEST(eth0) 192.168.0.230 00:23:54:7c:c6:0b

Aug 25 06:53:24 [dnsmasq] DHCPACK(eth0) 192.168.0.230 00:23:54:7c:c6:0b v1per-PC

Aug 25 06:53:24 [dnsmasq] requested options: 1:netmask, 15:domain-name, 3:router, 6:dns-server,

Aug 25 06:53:24 [dnsmasq] requested options: 44:netbios-ns, 46:netbios-nodetype, 47:netbios-scope,

Aug 25 06:53:24 [dnsmasq] requested options: 31:router-discovery, 33:static-route, 121:classless-static-route,

Aug 25 06:53:24 [dnsmasq] requested options: 249, 43:vendor-encap

Aug 25 06:53:24 [dnsmasq] sent size:  1 option: 53:message-type  05

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 54:server-identifier  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 51:lease-time  00:01:51:80

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 58:T1  00:00:a8:c0

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 59:T2  00:01:27:50

Aug 25 06:53:24 [dnsmasq] sent size:  4 option:  1:netmask  ff:ff:ff:00

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 28:broadcast  c0:a8:00:ff

Aug 25 06:53:24 [dnsmasq] sent size:  4 option:  3:router  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size:  4 option:  6:dns-server  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size: 11 option: 81:FQDN  03:ff:ff:76:31:70:65:72:2d:50:43

Aug 25 06:53:24 [dnsmasq] sent size:  0 option: 47:netbios-scope

Aug 25 06:53:24 [dnsmasq] sent size:  1 option: 46:netbios-nodetype  08

Aug 25 06:53:24 [dnsmasq] sent size:  4 option: 44:netbios-ns  c0:a8:00:01

Aug 25 06:53:24 [dnsmasq] sent size:  7 option: 43:vendor-encap  02:04:00:00:00:01:ff

Aug 25 06:53:40 [dnsmasq] DHCP packet: transaction-id is 2418584057

Aug 25 06:53:40 [dnsmasq] Available DHCP range: 192.168.0.200 -- 192.168.0.250

Aug 25 06:53:40 [dnsmasq] Vendor class: MSFT 5.0

Aug 25 06:53:40 [dnsmasq] DHCPINFORM(eth0) 192.168.0.230 00:23:54:7c:c6:0b

Aug 25 06:53:40 [dnsmasq] DHCPACK(eth0) 192.168.0.230 00:23:54:7c:c6:0b v1per-PC

Aug 25 06:53:40 [dnsmasq] requested options: 1:netmask, 15:domain-name, 3:router, 6:dns-server,

Aug 25 06:53:40 [dnsmasq] requested options: 44:netbios-ns, 46:netbios-nodetype, 47:netbios-scope,

Aug 25 06:53:40 [dnsmasq] requested options: 31:router-discovery, 33:static-route, 121:classless-static-route,

Aug 25 06:53:40 [dnsmasq] requested options: 249, 43:vendor-encap, 252

Aug 25 06:53:40 [dnsmasq] sent size:  1 option: 53:message-type  05

Aug 25 06:53:40 [dnsmasq] sent size:  4 option: 54:server-identifier  c0:a8:00:01

Aug 25 06:53:40 [dnsmasq] sent size:  4 option: 51:lease-time  00:01:51:70

Aug 25 06:53:40 [dnsmasq] sent size:  4 option:  1:netmask  ff:ff:ff:00

Aug 25 06:53:40 [dnsmasq] sent size:  4 option: 28:broadcast  c0:a8:00:ff

Aug 25 06:53:40 [dnsmasq] sent size:  4 option:  3:router  c0:a8:00:01

Aug 25 06:53:40 [dnsmasq] sent size:  4 option:  6:dns-server  c0:a8:00:01

Aug 25 06:53:40 [dnsmasq] sent size:  0 option: 47:netbios-scope

Aug 25 06:53:40 [dnsmasq] sent size:  1 option: 46:netbios-nodetype  08

Aug 25 06:53:40 [dnsmasq] sent size:  4 option: 44:netbios-ns  c0:a8:00:01

Aug 25 06:53:40 [dnsmasq] sent size:  7 option: 43:vendor-encap  02:04:00:00:00:01:ff

```

----------

## tutaepaki

I have a very similar config, and it works fine. (only difference, is that I specify the mask in the dhcp range, but that should not be required)

Maybe dnsmasq thinks the reserved address is already in use. Check the /var/lib/misc/dnsmasq.leases file, and if there is an entry for your reserved address, delete it. (you might need to restart dnsmasq after)

----------

## v1pEr

 *tutaepaki wrote:*   

> I have a very similar config, and it works fine. (only difference, is that I specify the mask in the dhcp range, but that should not be required)
> 
> Maybe dnsmasq thinks the reserved address is already in use. Check the /var/lib/misc/dnsmasq.leases file, and if there is an entry for your reserved address, delete it. (you might need to restart dnsmasq after)

 

```
RoSe v1per # cat /var/lib/misc/dnsmasq.leases

1251390293 00:23:54:7c:c6:0b 192.168.0.230 hostname 01:00:23:54:7c:c6:0b

1251353818 00:18:84:1e:b8:9c 192.168.0.248 * 01:00:18:84:1e:b8:9c
```

Doesn't seem to be in use (well it is now, but when I disconnect the pc, it disappears)

----------

