create_ap
create_ap copied to clipboard
Static IP for client
Is it possible to assign a static IP address to a certain client, e.g. based on the client's Mac address?
I have the same question here.
create_ap
writes the dhcp config to $CONFDIR/dnsmasq.conf
. One has to insert a line similar to
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.12.nnn
to the dnsmasq.conf
in order to assign always the same ip address to the same device. I don't want to insert the line directly in the script create_ap
since the next update would overwrite the changes. Is there a clean way to achieve this?
From my understanding, I am afraid, no.
You have found the right solution. As create_ap use its own dnsmasq.conf
file to run dnsmasq, one can only change it by modifying create_ap itself like you said.
However, you can use a separate file to specify mac/ip and use the option --dhcp-hostsfile=/path/to/myhostfile
of dnsmasq in create_ap code (line 1802 ?)
This way you store your config of mac/IP in a separate file that will not be overwritten by an update of create_ap. You will only have to update create_ap to make dnsmasq use your file.
You can make a patch for your change and apply it automatically when create_ap is updated.
--- /usr/bin/create_ap 2017-02-11 11:56:34.000000000 +0100
+++ /usr/bin/create_ap 2018-04-14 21:03:02.942731942 +0200
@@ -1799,7 +1799,7 @@
fi
umask 0033
- dnsmasq -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid -l $CONFDIR/dnsmasq.leases -p $DNS_PORT || die
+ dnsmasq --dhcp-hostsfile=/path/to/myhostfile -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid -l $CONFDIR/dnsmasq.leases -p $DNS_PORT || die
umask $SCRIPT_UMASK
fi
Hi everyone. I am looking for a way to get static IP addresses regarding MAC addresses with create_ap. I tried the solution above but that did not work. Are there some updates regarding this feature with create_ap? Thanks for your time.
I need this too. Not sure why there seems little will to do this obvious and simple thing.