summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2025-09-18 12:14:24 +0100
committerGitHub <noreply@github.com>2025-09-18 12:14:24 +0100
commit119e9fedbdd10abdc6e65f8e25dff04b58c37781 (patch)
tree859f4105ec074bc3aed6e1f39a45ec79d02a162f /smoketest/scripts/cli
parent02c32914f60b4cbda4470967afe120325188bc28 (diff)
parentae732fb0eb1dd352ba0b97b07aaf3db9c514ea19 (diff)
downloadvyos-1x-119e9fedbdd10abdc6e65f8e25dff04b58c37781.tar.gz
vyos-1x-119e9fedbdd10abdc6e65f8e25dff04b58c37781.zip
Merge pull request #4708 from sarthurdev/T114
wlb: T114: Add firewall group support for WAN load balancer
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_load-balancing_wan.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_load-balancing_wan.py b/smoketest/scripts/cli/test_load-balancing_wan.py
index 904dabd04..2b262a006 100755
--- a/smoketest/scripts/cli/test_load-balancing_wan.py
+++ b/smoketest/scripts/cli/test_load-balancing_wan.py
@@ -369,5 +369,62 @@ echo "$ifname - $state" > {hook_output_path}
with open(hook_output_path, 'r') as f:
self.assertIn('eth0 - FAILED', f.read())
+ def test_firewall_groups(self):
+ isp1_iface = 'eth0'
+ isp2_iface = 'eth1'
+ lan_iface = 'eth2'
+
+ network_group1 = 'NET1'
+ network_group2 = 'NET2'
+ port_group = 'PORT1'
+
+ self.cli_set(['interfaces', 'ethernet', isp1_iface, 'address', '203.0.113.2/30'])
+ self.cli_set(['interfaces', 'ethernet', isp2_iface, 'address', '192.0.2.2/30'])
+ self.cli_set(['interfaces', 'ethernet', lan_iface, 'address', '198.51.100.2/30'])
+
+ self.cli_set(['firewall', 'group', 'network-group', network_group1, 'network', '10.0.0.0/8'])
+ self.cli_set(['firewall', 'group', 'network-group', network_group2, 'network', '198.51.100.0/24'])
+ self.cli_set(['firewall', 'group', 'port-group', port_group, 'port', '53'])
+
+ self.cli_set(base_path + ['wan', 'interface-health', isp1_iface, 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', isp1_iface, 'nexthop', '203.0.113.2'])
+ self.cli_set(base_path + ['wan', 'interface-health', isp1_iface, 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', isp2_iface, 'failure-count', '1'])
+ self.cli_set(base_path + ['wan', 'interface-health', isp2_iface, 'nexthop', '192.0.2.2'])
+ self.cli_set(base_path + ['wan', 'interface-health', isp2_iface, 'success-count', '1'])
+ self.cli_set(base_path + ['wan', 'rule', '5', 'exclude'])
+ self.cli_set(base_path + ['wan', 'rule', '5', 'inbound-interface', 'eth*'])
+ self.cli_set(base_path + ['wan', 'rule', '5', 'destination', 'group', 'network-group', network_group1])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'failover'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'inbound-interface', lan_iface])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'protocol', 'udp'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'source', 'group', 'network-group', network_group2])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'source', 'group', 'port-group', port_group])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'destination', 'address', '192.0.2.0/24'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'destination', 'group', 'port-group', port_group])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'interface', isp1_iface])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'interface', isp1_iface, 'weight', '10'])
+ self.cli_set(base_path + ['wan', 'rule', '10', 'interface', isp2_iface])
+
+ # commit changes
+ self.cli_commit()
+
+ time.sleep(5)
+
+ nftables_search = [
+ ['iifname "eth*"', f'ip daddr @N_{network_group1}', 'return'],
+ [
+ f'iifname "{lan_iface}"',
+ f'ip saddr @N_{network_group2}',
+ f'udp sport @P_{port_group}',
+ 'ip daddr 192.0.2.0/24',
+ f'udp dport @P_{port_group}',
+ f'jump wlb_mangle_isp_{isp1_iface}',
+ ],
+ ]
+
+ self.verify_nftables_chain(nftables_search, 'ip vyos_wanloadbalance', 'wlb_mangle_prerouting')
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)