1
mirror of https://git.dn42.dev/wiki/wiki.git synced 2024-11-23 07:43:29 +01:00
wiki/howto/OpenWRT.md

83 lines
2.9 KiB
Markdown
Raw Normal View History

2013-12-06 19:29:59 +01:00
# dn42 on OpenWRT
This page gives hints on how to participate to dn42 with an OpenWRT router. It assumes Attitude Adjustment (12.09), but you can adapt it for other versions.
The intended target is a home router, acting as the default gateway for its LAN clients. The goal is to have one or more dn42 peers, announce the LAN subnet with BGP, and thus transparently provide dn42 access to the LAN clients.
This documentation assumes that the LAN is addressed in the dn42 space (`172.22.0.0/15`), but it's not a big deal to add NAT if it's not.
2013-12-06 22:01:19 +01:00
## Initial configuration
2013-12-06 19:29:59 +01:00
2013-12-06 22:01:19 +01:00
## Peerings
2013-12-06 19:29:59 +01:00
Nothing fancy: use GRE tunnels, openvpn, anything. Don't forget to install the relevant packages with `opkg` (`kmod-gre` for instance).
You can't manage GRE tunnels with OpenWRT, so just create them in `/etc/rc.local` (and assign addresses if needed).
2013-12-06 22:01:19 +01:00
## BGP
2013-12-06 19:29:59 +01:00
`quagga` and `bird` are both packaged in OpenWRT. Note that quagga is split in many packages, you probably need `quagga-bgpd`, `quagga-vtysh` and `quagga-zebra`.
2013-12-07 23:23:12 +01:00
Of course, you should announce the prefix of your home network.
2013-12-06 22:01:19 +01:00
## Interface definition
2013-12-06 19:29:59 +01:00
This is needed so that OpenWRT is aware of the new interfaces (for firewall and stuff).
In `/etc/config/network`, add entries for each dn42 interface:
config interface dn42peer1
option ifname tun-peer1
option proto none
2013-12-06 22:01:19 +01:00
## Firewall
2013-12-06 19:29:59 +01:00
There are two goals:
- Allowing traffic from LAN to dn42 (and maybe from dn42 to LAN too)
- If you have more than one peer, allowing traffic from dn42 to dn42 (forwarding)
2013-12-06 20:33:55 +01:00
Everything is done in `/etc/config/firewall`.
2013-12-06 22:01:19 +01:00
### Zone declaration
2013-12-06 20:33:55 +01:00
config zone
option name dn42
option network 'dn42peer1 dn42peer2 dn42peer3'
option input REJECT
option output ACCEPT
option forward REJECT
If you need to NAT your home network into dn42, you probably just need to add:
option masq 1
2013-12-06 22:01:19 +01:00
### dn42 ↔ LAN forwarding
2013-12-06 20:33:55 +01:00
config forwarding
option src lan
option dest dn42
If you're confident enough, you can also forward dn42 into your LAN:
config forwarding
option src dn42
option dest lan
2013-12-07 15:46:35 +01:00
Or you can forward only certain ports, to certain hosts, etc (standard `config rule` stuff)
2013-12-06 20:33:55 +01:00
2013-12-06 22:01:19 +01:00
### dn42 ↔ dn42 forwarding
2013-12-06 20:33:55 +01:00
2013-12-07 15:46:35 +01:00
This is more tricky. In theory, all you have to do is to set
option forward ACCEPT
in the definition of the zone. However, due to a bug in Attitude Adjustment (see https://dev.openwrt.org/ticket/12945), this will allow forwarding **everything everywhere**.
You have to use this patch: https://dev.openwrt.org/changeset/35484 (monkeypatching the relevant files in `/lib` should work).
2013-12-06 20:33:55 +01:00
2013-12-06 22:01:19 +01:00
## DNS
2013-12-06 18:29:59 +01:00
2015-01-01 21:39:33 +01:00
See [[DNS Configuration|/services/dns/Configuration]]. This will use the anycast dn42 DNS server to resolve `dn42` and relevant reverse domains.