Assign static ip address to local devices

Just recently installed open-wrt on my netgear D7800, I have a solar controller that needs to stay on a fixed IP address, I've set a static address and iit has been working great, today however, I had to reboot the router and it has changed the address on the solar controller. I've tried changing it back to the address I need it to be (192.168.1.19) but it's not changing. My internal network is only using IPv4. Can someone help me correct this issue please.

Is the address statically configured on the client or it is a DHCP reservation configured on the router?
If the address is manually configured on the client, is it inside or outside the DHCP pool?

1 Like

it's set in the router. I set it in static leases. (which may be the wrong way to do it)

have you tried restarting the solar controller (its mac address may vary ? is it wifi ?)

it's been assigned a different IP address - shows in the router as 192.168.1.31 (the monitoring software has encrypted authentication that only validates on 192.168.1.19)

Assuming you made this IP address reservation for a valid MAC that is absolutely acceptable. See what's in the system log.
DNSMASQ gives you some freedom on choosing the address:

Addresses allocated like this are not constrained to be in the range given by the --dhcp-range option, but they must be in the same subnet as some valid dhcp-range.

2 Likes

and yes, it's a WIFI connection - the MAC address has not changed

Please run the following commands (copy-paste the whole block) and paste the output here, using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have

ubus call system board; \
uci export network; \
uci export dhcp; \
ip -4 addr ; ip -4 ro li tab all ; ip -4 ru

3 Likes
{
        "kernel": "5.10.176",
        "hostname": "OpenWrt",
        "system": "ARMv7 Processor rev 0 (v7l)",
        "model": "Netgear Nighthawk X4 D7800",
        "board_name": "netgear,d7800",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "22.03.5",
                "revision": "r20134-5f15225c1e",
                "target": "ipq806x/generic",
                "description": "OpenWrt 22.03.5 r20134-5f15225c1e"
        }
}
package network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd7d:ac1d:3396::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1.1'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.254'
        option netmask '255.255.255.0'

config interface 'wan'
        option proto 'pppoe'
        option password 
        option ipv6 '0'
        option peerdns '0'
        list dns '8.8.8.8'
        option username 
        option device 'eth0.2'

config interface 'wan6'
        option device 'eth0.2'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '1 2 3 4 6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '5 0t'

package dhcp

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option localservice '1'
        option ednspacket_max '1232'

config dhcp 'lan'
        option interface 'lan'
        option dhcpv4 'server'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'
        option start '2'
        option limit '100'
        option ra 'hybrid'
        option dhcpv6 'hybrid'
        option leasetime '48h'
        option netmask '255.255.255.0'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'
        option start '100'
        option limit '150'
        option leasetime '12h'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

config host
        option name 'Robs-Nuc'
        option dns '1'
        option mac '1C:69:7A:##:##:##'
        option ip '192.168.1.25'
        option leasetime '0'

config host
        option name 'Bedroom-Spk'
        option dns '1'
        option mac '48:A9:D2:##:##:##'
        option ip '192.168.1.9'
        option leasetime '0'

config host
        option mac '90:56:82:##:##:##'
        option ip '192.168.1.10'
        option name 'Kitchen-Spk'
        option dns '1'
        option leasetime '0'

config host
        option name 'Left-Spk'
        option dns '1'
        option mac '90:56:82:##:##:##'
        option ip '192.168.1.12'
        option leasetime '0'

config host
        option name 'Right-Spk'
        option dns '1'
        option mac '90:56:82:##:##:##'
        option ip '192.168.1.14'
        option leasetime '0'

config host
        option name 'Home-Cloud'
        option dns '1'
        option mac '## ## ## ##'
        option ip '192.168.1.61'
        option leasetime '0'

config host
        option name 'Envoy'
        option dns '1'
        option mac '64:33:DB:##:##:##'
        option ip '192.168.1.19'
        option leasetime '0'

config host
        option name 'R7000'
        option dns '1'
        option mac 'E4:F4:C6:##:##:##'
        option ip '192.168.1.1'
        option leasetime '0'

config host
        option name 'Audio-Pro'
        option dns '1'
        option mac '00:22:6C:##:##:##'
        option ip '192.168.1.41'
        option leasetime '0'

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
7: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    inet 192.168.1.254/24 brd 192.168.1.255 scope global br-lan
       valid_lft forever preferred_lft forever
10: pppoe-wan: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1492 qdisc fq_codel state UNKNOWN qlen 3
    inet 
192.168.1.0/24 dev br-lan scope link  src 192.168.1.254
broadcast 127.0.0.0 dev lo table local scope link  src 127.0.0.1
local 127.0.0.0/8 dev lo table local scope host  src 127.0.0.1
local 127.0.0.1 dev lo table local scope host  src 127.0.0.1
broadcast 127.255.255.255 dev lo table local scope link  src 127.0.0.1
local #.#.#.# dev pppoe-wan table local scope host  src #:#:#:
broadcast 192.168.1.0 dev br-lan table local scope link  src 192.168.1.254
local 192.168.1.254 dev br-lan table local scope host  src 192.168.1.254
broadcast 192.168.1.255 dev br-lan table local scope link  src 192.168.1.254
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

your gateway 192.168.1.254
broadcast address 192.168.1.255


so that your leases are between 192.168.1.50 and 192.168.1.151

and your hosts with pre-assigned ip addresses are between 192.168.1.2 and 192.168.1.49
and from 192.168.1.152 and 192.168.1.253

/etc/init.d/dhcp restart

and restarting the solar controller for change ip address assigment

change this: (48h lease too much)

config dhcp 'lan'
        option interface 'lan'
        option dhcpv4 'server'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'
        option start '50'
        option limit '100'
        option ra 'hybrid'
        option dhcpv6 'hybrid'
        option leasetime '12h'

change this: (wan not lease, not dhcp server)

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

change this:

config host
        option name 'Home-Cloud'
        option dns '1'
        option mac '## ## ## ##'
        option ip '192.168.1.31'
        option leasetime '0'

my /etc/config/dhcp is (why do you need the other options ipv6 or other?):

config dhcp 'lan'
        option interface 'lan'
        option start '50'
        option limit '100'
        option leasetime '12h'
        option dhcpv4 'server'
3 Likes

I hope this host does not provide any DHCP servers on the network ...

to verify ...

config host
        option name 'R7000'
        option dns '1'
        option mac 'E4:F4:C6:##:##:##'
        option ip '192.168.1.1'
        option leasetime '0

No, it just operates as an access point in a garden building

1 Like

ok

dump-ac on garden

Did everything that was advised here, but made no difference initially.

Eventually sorted it by turning off the electricity supply for a couple of minutes. All IP Addresses now work how I want

Thanks for all the help, really appreciated.

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.
Thanks! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.