Skip to content

Add OpenWrt router guide #1232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/images/routers/openwrt-dhcp-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/routers/openwrt-dns-forward.png
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this image can be cropped. The relevant section is only in the upper quarter of it.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions docs/routers/openwrt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# OpenWrt

Here's a short guide to configure Pi-hole as the DNS server for your OpenWrt router.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Here's a short guide to configure Pi-hole as the DNS server for your OpenWrt router.

This guide was written for OpenWrt version 24.10 but the principle should hold for any earlier or later release although Web UI might look different.

## Requirements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole section is not needed. It should be clear that a guide for OpenWrt & Pi-hole requires an OpenWrt router and Pi-hole....


* OpenWrt router (already installed and accessible)
* Pi-hole installed on a device in your network (e.g. Raspberry Pi or LXC container)
* Access to OpenWrt LuCI Web Interface or SSH terminal

## Configuration

Ensure Pi-hole has a fixed IP. For example: `192.168.1.2`.

### Option 1: Tell DHCP clients to use Pi-hole (Recommended)

#### Web UI: Network > Interfaces > LAN

For the selected interface, eg *lan*, click *Edit*. Then under *DHCP Server* > *Advanced settings* set *DHCP-Options*:

`6,192.168.1.2`

*Meaning: 6 = DNS server, followed by IP.*

![Screenshot of OpenWrt interface DHCP settings](../images/routers/openwrt-dhcp-options.png)

#### Terminal:

```shell
$ uci add_list dhcp.lan.dhcp_option='6,192.168.1.2'
<no output>
$ uci commit dhcp
<no output>
$ /etc/init.d/dnsmasq restart
<no output>
```

### Option 2: Forward requests to Pi-hole

*Note: This makes all requests look like they come from the router in Pi-hole.*

#### Web UI: Network > DHCP and DNS > Forwards

Add your Pi-hole IP under DNS forwards

![Screenshot of OpenWrt DNS forwarding settings](../images/routers/openwrt-dns-forward.png)

#### Terminal:

```shell
$ uci add_list dhcp.@dnsmasq[0].server='192.168.1.2'
<no output>
$ uci commit dhcp
<no output>
$ /etc/init.d/dnsmasq restart
<no output>
```

### Restart Network Clients

Reboot your devices or release/renew their DHCP leases so they pick up the new DNS server.

## Verification

On a client, run:

```shell
$ nslookup example.com
Server: 192.168.1.2
Address: 192.168.1.2#53
```

Ensure the server address is your Pi-hole IP.

Visit the Pi-hole dashboard and check query log for activity.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ nav:
- 'Fritz!Box (EN)': routers/fritzbox.md
- 'Fritz!Box (DE)': routers/fritzbox-de.md
- 'Nokia G-240W-B': routers/nokia-G240WB.md
- 'OpenWrt': routers/openwrt.md
- 'OPNsense': routers/OPNsense.md
- 'TP-Link': routers/tp-link.md
- 'Ubiquiti USG': routers/ubiquiti-usg.md
Expand Down