You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/ns-ha/README.md
+76Lines changed: 76 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,48 @@ This package is a set of scripts to configure a high availability firewall.
4
4
Configured with keepalived, it will provide a failover mechanism between two nodes.
5
5
6
6
Requirements:
7
+
- 2 nodes with similar hardware
7
8
- nodes must be connected to the same LAN
8
9
- nodes must have a dedicated interface for the HA configuration
9
10
- nodes must have only one WAN interface configured with DHCP
10
11
12
+
Limitations:
13
+
14
+
- WAN must be configured in DHCP
15
+
- extra packages like NUT are not supported
16
+
- rsyslog configuration is not synced: if you need to send logs to a remote server, you must use the controller
17
+
- hotspot is not supported since it requires a new registration when the master node goes down because the MAC address associated to the hotspot interface will be different
18
+
19
+
The following features are supported:
20
+
21
+
- Firewall rules, including port forwarding
22
+
- DHCP and DNS server
23
+
- SSH server (dropbear)
24
+
- OpenVPN RoadWarrior and tunnels
25
+
- IPsec tunnels (strongwan)
26
+
- WireGuard tunnels
27
+
- Static routes
28
+
- QoS (qosify)
29
+
- Multi-WAN (mwan3)
30
+
- DPI rules
31
+
- Netifyd informatics configuration
32
+
- Threat shield IP (banip)
33
+
- Threat shield DNS (adblock)
34
+
- Reverse proxy (nginx)
35
+
- ACME certificates
36
+
- Users and objects database
37
+
- Netmap
38
+
- Flashstart
39
+
- SNMP server (snmpd)
40
+
- NAT helpers
41
+
- Dynamic DNS (ddns)
42
+
- SMTP client (msmtp)
43
+
- Backup encryption password
44
+
- Controller connection and subscription (ns-plug)
45
+
- Active connections tracking (conntrackd) - NOT tested
46
+
47
+
## Configuration
48
+
11
49
The setup process will configure all the following:
12
50
- create a new firewall zone `ha`
13
51
- configure the HA interface, the one dedicated for the HA traffic
@@ -56,3 +94,41 @@ In this example:
56
94
/etc/init.d/firewall restart
57
95
/etc/init.d/keepalived restart
58
96
```
97
+
98
+
## How it works
99
+
100
+
The HA is always composed by two nodes: one is the master and the other is the backup.
101
+
All configuration must be node always on the master node.
102
+
The configuration is then automatically synchronized to the backup node.
103
+
104
+
The keepalived configuration uses a special crafted rsync script named `/etc/keepalived/scripts/ns-rsync.sh`.
105
+
106
+
The script is executed on the primary node, when it is master, at regular intervals and it will:
107
+
- export WireGuard interfaces, IPsec interfaces and routes to a special directory named `/etc/ha`
108
+
- synchronize all files listed inside by `sysupgrade -l` and all files added with the `add_sync_file` option from scripts inside `/etc/hotplug.d/keepalived` directory;
109
+
files are synchronized to backup node inside the directory `/usr/share/keepalived/rsync/`
110
+
111
+
The hotplug `keepalived` event is used to inform the system about changes in the keepalived status.
112
+
113
+
The event is triggered with an `ACTION` parameter that can be:
114
+
115
+
- `NOTIFY_SYNC`: the script is executed on the backup node, after a sync has been done and a listed file is changed
116
+
During this phase all directories (like `/etc/openvpn` and `/etc/ha`) are synched to the original position.
117
+
Also WireGuard interfaces, IPsec interfaces and routes are imported from the `/etc/ha` directory but in disabled state.
118
+
119
+
- `NOTIFY_MASTER`: the script can be executed both on the master and on the backup node:
120
+
- on the master node, after keepalived is started: this is the normal startup state
121
+
- on the backup node, after an switchover has been done: this is the failover state;
122
+
all WireGuard interfaces, IPsec interfaces and routes previously imported from the `/etc/ha` are enabled if they were enabled on the master node
123
+
124
+
- `NOTIFY_BACKUP`: the script is executed on the backup node, after keepalived is started or if the master returns up after a downtime
125
+
All non required services are disabled, including WireGuard interfaces, IPsec interfaces and routes.
126
+
127
+
The backup node keeps the configuration in sync with the master node, but most services, including crontabs, are disabled.
128
+
The following cronjobs are disabled on the backup node and enabled on the master node:
0 commit comments