Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:network:high-availability [2021/05/25 15:49] – alt_config_file - mention and explain risk | docs:guide-user:network:high-availability [2022/08/31 20:55] – Fixed error in uci file header preventing use of alt config file nathhad | ||
|---|---|---|---|
| Line 99: | Line 99: | ||
| </ | </ | ||
| - | To ensure `/ | + | To ensure `/ |
| + | |||
| + | write the following in `/ | ||
| < | < | ||
| - | config | + | config |
| | | ||
| </ | </ | ||
| - | This above will cause the init script | + | This will tell the keepalived service |
| ==== 4. Configure conntrackd ==== | ==== 4. Configure conntrackd ==== | ||
| Line 181: | Line 183: | ||
| </ | </ | ||
| - | ==== 3. Configure dhcp ==== | + | ==== 5. Configure dhcp ==== |
| You'll want DHCP (dnsmasq) to serve 192.168.0.4 (vip address) to hosts on the lan, both as their gateway and DNS. | You'll want DHCP (dnsmasq) to serve 192.168.0.4 (vip address) to hosts on the lan, both as their gateway and DNS. | ||
| Line 197: | Line 199: | ||
| dhcp_option 3 is gateway, dhcp_option 6 is DNS. | dhcp_option 3 is gateway, dhcp_option 6 is DNS. | ||
| - | ==== 5. Sysupgrade backup add dirs ==== | + | Now we need to configure synchronization of the dhcp leases. Both devices will have a dhcp server and both will assign dynamic IPs to clients. But each will only update its own dhcp lease list. |
| + | |||
| + | Dnsmasq stores current leases in a text file called **/ | ||
| + | |||
| + | This is what it looks like on my OpenWrt router VM | ||
| + | < | ||
| + | root@VM-router: | ||
| + | 1633703346 00: | ||
| + | 1633703352 c4: | ||
| + | 1633703161 c0: | ||
| + | 1633703141 e8: | ||
| + | </ | ||
| + | The first number is a timestamp (seconds since Unix " | ||
| + | |||
| + | So we add a simple and dumb script that just merges the files on both devices every X time, and it assumes that dnsmasq will automatically drop the entries when their lease is up. | ||
| + | |||
| + | We must do the following on both routers. | ||
| + | |||
| + | Import the public SSH key of the router 1 in router 2 (and the reverse) so they can scp to each other without writing the password | ||
| + | this to read the current public key [[docs: | ||
| + | and this to write the key [[docs: | ||
| + | |||
| + | Then copy the following script to **/ | ||
| + | |||
| + | < | ||
| + | #!/bin/sh | ||
| + | #syncs contents of dnsmasq dhcp leases | ||
| + | |||
| + | other_router=192.168.11.254 | ||
| + | |||
| + | scp root@$other_router:/ | ||
| + | |||
| + | cat / | ||
| + | |||
| + | mv / | ||
| + | </ | ||
| + | |||
| + | then make it executable | ||
| + | < | ||
| + | chmod u+x / | ||
| + | </ | ||
| + | Then add a scheduled task to execute this script every minute and enable cron (scheduled tasks) service. (can be done from luci as well [[docs: | ||
| + | |||
| + | < | ||
| + | echo '*/1 * * * * / | ||
| + | echo ' | ||
| + | service cron start | ||
| + | </ | ||
| + | |||
| + | ==== 6. Sysupgrade backup add dirs ==== | ||
| Add the following directories to ''/ | Add the following directories to ''/ | ||
| Line 204: | Line 255: | ||
| / | / | ||
| / | / | ||
| + | / | ||
| </ | </ | ||