summaryrefslogtreecommitdiff
path: root/data/templates/load-balancing
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-04 15:32:43 +0200
committerGitHub <noreply@github.com>2023-05-04 15:32:43 +0200
commitba81c15185d7a59ab0ec6705b53b311b4dda721d (patch)
tree669b9092b127dae24bbc28eb8ffa5c138bfba613 /data/templates/load-balancing
parentd6364153436505ff6c25ce8b438ad204c927a1d1 (diff)
parenteac5dc2b1f7be06f0d7a4e35f8850a0c1f514fa0 (diff)
downloadvyos-1x-ba81c15185d7a59ab0ec6705b53b311b4dda721d.tar.gz
vyos-1x-ba81c15185d7a59ab0ec6705b53b311b4dda721d.zip
Merge pull request #1973 from sever-sever/T5171
T5171: Use XML for loadbalancing wan instead of old templates
Diffstat (limited to 'data/templates/load-balancing')
-rw-r--r--data/templates/load-balancing/wlb.conf.j2130
1 files changed, 130 insertions, 0 deletions
diff --git a/data/templates/load-balancing/wlb.conf.j2 b/data/templates/load-balancing/wlb.conf.j2
new file mode 100644
index 000000000..d3326b6b8
--- /dev/null
+++ b/data/templates/load-balancing/wlb.conf.j2
@@ -0,0 +1,130 @@
+# Generated by /usr/libexec/vyos/conf_mode/load-balancing-wan.py
+
+{% if disable_source_nat is vyos_defined %}
+disable-source-nat
+{% endif %}
+{% if enable_local_traffic is vyos_defined %}
+enable-local-traffic
+{% endif %}
+{% if sticky_connections is vyos_defined %}
+sticky-connections inbound
+{% endif %}
+{% if flush_connections is vyos_defined %}
+flush-conntrack
+{% endif %}
+{% if hook is vyos_defined %}
+hook "{{ hook }}"
+{% endif %}
+{% if interface_health is vyos_defined %}
+health {
+{% for interface, interface_config in interface_health.items() %}
+ interface {{ interface }} {
+{% if interface_config.failure_count is vyos_defined %}
+ failure-ct {{ interface_config.failure_count }}
+{% endif %}
+{% if interface_config.success_count is vyos_defined %}
+ success-ct {{ interface_config.success_count }}
+{% endif %}
+{% if interface_config.nexthop is vyos_defined %}
+ nexthop {{ interface_config.nexthop }}
+{% endif %}
+{% if interface_config.test is vyos_defined %}
+{% for test_rule, test_config in interface_config.test.items() %}
+ rule {{ test_rule }} {
+{% if test_config.type is vyos_defined %}
+{% set type_translate = {'ping': 'ping', 'ttl': 'udp', 'user-defined': 'user-defined'} %}
+ type {{ type_translate[test_config.type] }} {
+{% if test_config.ttl_limit is vyos_defined and test_config.type == 'ttl' %}
+ ttl {{ test_config.ttl_limit }}
+{% endif %}
+{% if test_config.test_script is vyos_defined and test_config.type == 'user-defined' %}
+ test-script {{ test_config.test_script }}
+{% endif %}
+{% if test_config.target is vyos_defined %}
+ target {{ test_config.target }}
+{% endif %}
+ resp-time {{ test_config.resp_time | int * 1000 }}
+ }
+{% endif %}
+ }
+{% endfor %}
+{% endif %}
+ }
+{% endfor %}
+}
+{% endif %}
+
+{% if rule is vyos_defined %}
+{% for rule, rule_config in rule.items() %}
+rule {{ rule }} {
+{% if rule_config.exclude is vyos_defined %}
+ exclude
+{% endif %}
+{% if rule_config.failover is vyos_defined %}
+ failover
+{% endif %}
+{% if rule_config.limit is vyos_defined %}
+ limit {
+{% if rule_config.limit.burst is vyos_defined %}
+ burst {{ rule_config.limit.burst }}
+{% endif %}
+{% if rule_config.limit.rate is vyos_defined %}
+ rate {{ rule_config.limit.rate }}
+{% endif %}
+{% if rule_config.limit.period is vyos_defined %}
+ period {{ rule_config.limit.period }}
+{% endif %}
+{% if rule_config.limit.threshold is vyos_defined %}
+ thresh {{ rule_config.limit.threshold }}
+{% endif %}
+ }
+{% endif %}
+{% if rule_config.per_packet_balancing is vyos_defined %}
+ per-packet-balancing
+{% endif %}
+{% if rule_config.protocol is vyos_defined %}
+ protocol {{ rule_config.protocol }}
+{% endif %}
+{% if rule_config.destination is vyos_defined %}
+ destination {
+{% if rule_config.destination.address is vyos_defined %}
+ address "{{ rule_config.destination.address }}"
+{% endif %}
+{% if rule_config.destination.port is vyos_defined %}
+{% if '-' in rule_config.destination.port %}
+ port-ipt "-m multiport --dports {{ rule_config.destination.port | replace('-', ':') }}"
+{% else %}
+ port-ipt " --dport {{ rule_config.destination.port }}"
+{% endif %}
+{% endif %}
+ }
+{% endif %}
+{% if rule_config.source is vyos_defined %}
+ source {
+{% if rule_config.source.address is vyos_defined %}
+ address "{{ rule_config.source.address }}"
+{% endif %}
+{% if rule_config.source.port is vyos_defined %}
+{% if '-' in rule_config.source.port %}
+ port-ipt "-m multiport --sports {{ rule_config.source.port | replace('-', ':') }}"
+{% else %}
+ port.ipt " --sport {{ rule_config.source.port }}"
+{% endif %}
+{% endif %}
+ }
+{% endif %}
+{% if rule_config.inbound_interface is vyos_defined %}
+ inbound-interface {{ rule_config.inbound_interface }}
+{% endif %}
+{% if rule_config.interface is vyos_defined %}
+{% for interface, interface_config in rule_config.interface.items() %}
+ interface {{ interface }} {
+{% if interface_config.weight is vyos_defined %}
+ weight {{ interface_config.weight }}
+{% endif %}
+ }
+{% endfor %}
+{% endif %}
+}
+{% endfor %}
+{% endif %}