Debian Codegraph @

test/10-multi-isp/foomuuri.conf

raw
1 # Basic configuration:
2
3 zone {
4 # Define zones with interfaces
5 localhost
6 public enp1s0 enp2s0
7 internal enp8s0
8 }
9
10 foomuuri {
11 # Reverse path filtering must be disabled for public interfaces
12 rpfilter -enp1s0 -enp2s0
13 }
14
15 snat {
16 # Masquerade outgoing traffic from internal to public. Both ISPs must be
17 # masqueraded separately.
18 saddr 10.0.0.0/8 oifname enp1s0 masquerade
19 saddr 10.0.0.0/8 oifname enp2s0 masquerade
20 }
21
22 # Multi-ISP magic is here, using marks to select which ISP to use. Order
23 # of the rules is important. Specific rules should be first, generic last.
24
25 prerouting {
26 # Accept if mark is already set (not zero). Existing mark will be used.
27 mark_match -0x0000/0xff00
28
29 # == Incoming traffic ==
30
31 # Mark traffic from enp1s0 as 0x100 (ISP1) and enp2s0 as 0x200 (ISP2).
32 # This is needed for correctly routing reply packets.
33 iifname enp1s0 mark_set 0x100/0xff00
34 iifname enp2s0 mark_set 0x200/0xff00
35
36 # == Outgoing traffic ==
37
38 # Specific rules should be added first. For example, uncomment next line to
39 # route all SSH traffic from internal to public via ISP2.
40 #iifname enp8s0 ssh mark_set 0x200/0xff00
41
42 # Similarly, some source IPs can always be routed via ISP1.
43 #saddr 10.0.1.0/24 mark_set 0x100/0xff00
44
45 # For active-active configuration use following line. It uses random number
46 # generator to mark traffic with 0x100 or 0x200. This routes 60% (0-5)
47 # of outgoing traffic to ISP1 and 40% (6-9) to ISP2.
48 nft "meta mark set numgen random mod 10 map { 0-5: 0x100, 6-9: 0x200 } ct mark set meta mark accept"
49
50 # For active-passive configuration uncomment next line and add comment to
51 # above nft-line. It simply assigns mark 0x100 (ISP1) to all traffic and
52 # uses ISP2 only as fallback.
53 #mark_set 0x100/0xff00
54 }
55
56 hook {
57 # Setup "ip rule" and "ip route" rules when Foomuuri starts or stops.
58 # See below for example "multi-isp" file.
59 post_start /etc/foomuuri/multi-isp start
60 post_stop /etc/foomuuri/multi-isp stop
61 }
62
63 # foomuuri-monitor config:
64
65 target isp1 {
66 # Monitor ISP1 connectivity by pinging 8.8.4.4. Ideally this would be
67 # some ISP1's router's IP address.
68 command fping --iface enp1s0 8.8.4.4
69 command_up /etc/foomuuri/multi-isp up 1
70 command_down /etc/foomuuri/multi-isp down 1
71 }
72
73 target isp2 {
74 # Monitor ISP2 connectivity by pinging their router 172.25.31.149.
75 command fping --iface enp2s0 172.25.31.149
76 command_up /etc/foomuuri/multi-isp up 2
77 command_down /etc/foomuuri/multi-isp down 2
78 }
79
80 # Normal zone-zone rules, copied from router firewall example configuration:
81
82 public-localhost {
83 ping saddr_rate "5/second burst 20"
84 ssh saddr_rate "5/minute burst 5"
85 drop log
86 }
87
88 internal-localhost {
89 dhcp-server
90 dhcpv6-server
91 domain
92 domain-s
93 ntp
94 ping
95 ssh
96 reject log
97 }
98
99 template outgoing_services {
100 # Shared list of services for localhost-public and internal-public.
101 domain
102 domain-s
103 http
104 https
105 ntp
106 ping
107 smtp
108 ssh
109 }
110
111 localhost-public {
112 template outgoing_services
113 reject log
114 }
115
116 internal-public {
117 template outgoing_services
118 googlemeet
119 imap
120 reject log
121 }
122
123 public-internal {
124 drop log
125 }
126
127 localhost-internal {
128 dhcp-client
129 dhcpv6-client
130 ping
131 ssh
132 reject log
133 }