mattlongman / Hassio-Access-Point

Hass.io addon to let you create a WiFi access point, perfect for using WiFi devices on off-grid installations.
MIT License
81 stars 62 forks source link

Reserved IP #19

Closed mezen closed 2 years ago

mezen commented 2 years ago

Hi,

is it possible to always assign a reserved ip adress to specific devices to prevent ip switching over time?

AndyOne77 commented 2 years ago

support. A very useful function.

esotericnonsense commented 2 years ago

I have put together a pull request for this functionality in #23.

Dejv311 commented 2 years ago

HI! This addon does not allow you to do this, but after a few hours of reverse-engineering the whole thing I found a way to work around it. Basically I am using code injection to add a line specifying mac->ip reservation. The IP needs to be in the "range" specified above. There can be multiple lines of "dhcp-host" added specifying multiple reservations. The hashtag at the last line is very important - do not remove it!! Hope this helps :)

My config:

ssid: MyWifi
wpa_passphrase: password123
channel: '6'
address: 192.168.99.1
netmask: 255.255.255.0
broadcast: 192.168.99.255
interface: wlan0
hide_ssid: '1'
dhcp: '1'
dhcp_start_addr: 192.168.99.10
dhcp_end_addr: |-
  192.168.99.200,12h
  dhcp-host=12:34:56:78:90:AB,192.168.99.123
   #
allow_mac_addresses: []
deny_mac_addresses: []
debug: 0
hostapd_config_override: []
client_internet_access: '1'
client_dns_override: []
mattlongman commented 2 years ago

dnsmasq_config_override option should now provide this functionality (although combining into dhcp_end_addr as per @Dejv311 above does also work).

dnsmasq_config_override appends to dnsmasq config, as does the dhcp range.

Dejv311 commented 2 years ago

Hi, thank you. It looks like the update solved the issue! The dhcp_end_addr shenanigans are a left over from past versions, where dnsmasq_config_override did not exist. I will leave it like that since it looks cool :D. Anyways thanks again for your time!

mattlongman commented 2 years ago

Thanks @Dejv311. To confirm, you're talking about the issue on https://github.com/mattlongman/Hassio-Access-Point/issues/30?

Dejv311 commented 2 years ago

Sorry, wrong thread, yes it works now :)

mattlongman commented 2 years ago

Adding dhcp-host=12:34:56:78:90:AB,192.168.99.123 to dnsmasq_config_override is now the best way to do this.