create_ap icon indicating copy to clipboard operation
create_ap copied to clipboard

Static IP for client

Open fjulian opened this issue 6 years ago • 5 comments

Is it possible to assign a static IP address to a certain client, e.g. based on the client's Mac address?

fjulian avatar Feb 27 '18 00:02 fjulian

I have the same question here.

TomFischer avatar Mar 29 '18 18:03 TomFischer

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?

TomFischer avatar Mar 29 '18 19:03 TomFischer

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

solsticedhiver avatar Apr 14 '18 19:04 solsticedhiver

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.

yoarch avatar May 09 '19 13:05 yoarch

I need this too. Not sure why there seems little will to do this obvious and simple thing.

adrianmay avatar May 24 '20 10:05 adrianmay