Beginners guide to set Static IPs for your hosts

Hi! I'm very new to OpenWrt and I had trouble with a very simple task: I like to control which IPv4 each of my hosts will get. I read the docs of course but I still had trouble to read out the essential parts.

Now that static IPs work I provide you a condensed step-by-step guide for setting up static leases. You should still read the docs afterwards. I'm ignoring IPv6.

  1. At first let the device connect to your router. It will get a random IP from your DHCP range
  2. On the start page (Status > Overview) find the device from its name and copy its MAC address
  3. Connect via ssh and run vim /etc/config/dhcp
  4. At the end of the file add with your correct values:
    config host
         option name 'yourdevicename'
         option mac '12:34:56:78:9A:BC'
         option ip '192.168.1.xyz'
    
  5. Save and close the file
  6. Open the file with the active leases via vim /tmp/dhcp.leases
  7. Go to the line with the correct mac and type dd to delete it
  8. Run /etc/init.d/dnsmasq restart to restart DHCP
  9. Let your host disconnect and reconnect to your router. It has the correct IP address now.
  10. See Network > DHCP and DNS > Static Leases for all your static IPs

I know you can add static IPs on that page but as I said, this was the fastest and easiest way for me without hassling with other options, e.g. with luci I got dns = 1 written into the config file.

2 Likes

What item in list you do not understand?

This is not a question. This is a guide for whoever has trouble reading the essential parts of the docs for just setting up static IPs. OpenWrt has many many options and as a beginner I know it's hard to miss something or worse: to think some of the plenty options might interfer with what you are trying to achive.

EDIT: I see why you asked that. I've clarified above, that I'm just providing a guide.

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