|
|
c8bceb |
From 6e32ff7eabc88e57b4f4831eece15918fc4bda85 Mon Sep 17 00:00:00 2001
|
|
|
c8bceb |
From: Eric Garver <eric@garver.life>
|
|
|
c8bceb |
Date: Fri, 23 Aug 2019 15:00:45 -0400
|
|
|
c8bceb |
Subject: [PATCH 93/99] test: coverage to make sure masquerade/forward-port
|
|
|
c8bceb |
only affect IPv4
|
|
|
c8bceb |
|
|
|
c8bceb |
(cherry picked from commit 5605eefb65adbbe7d6980cc90245f940042c9b78)
|
|
|
c8bceb |
(cherry picked from commit 1340fac01a6d64458e7a751807a54c0a5b38dde3)
|
|
|
c8bceb |
---
|
|
|
c8bceb |
src/tests/firewall-cmd.at | 76 +++++++++++++++++++++++++++++++++++++++
|
|
|
c8bceb |
1 file changed, 76 insertions(+)
|
|
|
c8bceb |
|
|
|
c8bceb |
diff --git a/src/tests/firewall-cmd.at b/src/tests/firewall-cmd.at
|
|
|
c8bceb |
index 6a4b670d7935..590194103a7e 100644
|
|
|
c8bceb |
--- a/src/tests/firewall-cmd.at
|
|
|
c8bceb |
+++ b/src/tests/firewall-cmd.at
|
|
|
c8bceb |
@@ -438,6 +438,25 @@ FWD_END_TEST([-e '/ERROR: INVALID_PROTOCOL: dummy/d'])
|
|
|
c8bceb |
|
|
|
c8bceb |
FWD_START_TEST([masquerade])
|
|
|
c8bceb |
FWD_CHECK([--add-masquerade --zone=public], 0, ignore)
|
|
|
c8bceb |
+ dnl man page says this should only affect IPv4, so verify that.
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip], [nat_POST_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip firewalld {
|
|
|
c8bceb |
+ chain nat_POST_public_allow {
|
|
|
c8bceb |
+ oifname != "lo" masquerade
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip6], [nat_POST_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip6 firewalld {
|
|
|
c8bceb |
+ chain nat_POST_public_allow {
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IPTABLES_LIST_RULES([nat], [POST_public_allow], 0, [dnl
|
|
|
c8bceb |
+ MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IP6TABLES_LIST_RULES([nat], [POST_public_allow], 0, [dnl
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
FWD_CHECK([--query-masquerade], 0, ignore)
|
|
|
c8bceb |
FWD_CHECK([--remove-masquerade], 0, ignore)
|
|
|
c8bceb |
FWD_CHECK([--query-masquerade], 1, ignore)
|
|
|
c8bceb |
@@ -451,9 +470,47 @@ FWD_END_TEST
|
|
|
c8bceb |
FWD_START_TEST([forward ports])
|
|
|
c8bceb |
FWD_CHECK([--add-forward-port=666], 106, ignore, ignore)
|
|
|
c8bceb |
FWD_CHECK([--add-forward-port=port=11:proto=tcp:toport=22], 0, ignore)
|
|
|
c8bceb |
+ dnl man page says this should only affect IPv4, so verify that.
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip], [nat_PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip firewalld {
|
|
|
c8bceb |
+ chain nat_PRE_public_allow {
|
|
|
c8bceb |
+ meta l4proto tcp mark 0x00000064 redirect to :22
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip6], [nat_PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip6 firewalld {
|
|
|
c8bceb |
+ chain nat_PRE_public_allow {
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IPTABLES_LIST_RULES([nat], [PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 mark match 0x64 to::22
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IP6TABLES_LIST_RULES([nat], [PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
FWD_CHECK([--remove-forward-port=port=11:proto=tcp:toport=22 --zone=public], 0, ignore)
|
|
|
c8bceb |
FWD_CHECK([--add-forward-port=port=33:proto=tcp:toaddr=4444], 105, ignore, ignore) dnl bad address
|
|
|
c8bceb |
FWD_CHECK([--add-forward-port=port=33:proto=tcp:toaddr=4.4.4.4 --zone=public], 0, ignore)
|
|
|
c8bceb |
+ dnl man page says this should only affect IPv4, so verify that.
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip], [nat_PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip firewalld {
|
|
|
c8bceb |
+ chain nat_PRE_public_allow {
|
|
|
c8bceb |
+ meta l4proto tcp mark 0x00000064 dnat to 4.4.4.4
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip6], [nat_PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip6 firewalld {
|
|
|
c8bceb |
+ chain nat_PRE_public_allow {
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IPTABLES_LIST_RULES([nat], [PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 mark match 0x64 to:4.4.4.4
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IP6TABLES_LIST_RULES([nat], [PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
FWD_CHECK([--remove-forward-port=port=33:proto=tcp:toaddr=4.4.4.4], 0, ignore)
|
|
|
c8bceb |
FWD_CHECK([--add-forward-port=port=55:proto=tcp:toport=66:toaddr=7.7.7.7], 0, ignore)
|
|
|
c8bceb |
FWD_CHECK([--query-forward-port port=55:proto=tcp:toport=66:toaddr=7.7.7.7 --zone=public], 0, ignore)
|
|
|
c8bceb |
@@ -465,6 +522,25 @@ FWD_START_TEST([forward ports])
|
|
|
c8bceb |
FWD_CHECK([--query-forward-port=port=66:proto=sctp:toport=66:toaddr=7.7.7.7], 1, ignore)
|
|
|
c8bceb |
IF_IPV6_SUPPORTED([
|
|
|
c8bceb |
FWD_CHECK([--add-forward-port=port=66:proto=sctp:toport=66:toaddr=fd00:dead:beef:ff0::], 0, ignore)
|
|
|
c8bceb |
+ dnl this should only affect IPv6, so verify that.
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip], [nat_PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip firewalld {
|
|
|
c8bceb |
+ chain nat_PRE_public_allow {
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ NFT_LIST_RULES([ip6], [nat_PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ table ip6 firewalld {
|
|
|
c8bceb |
+ chain nat_PRE_public_allow {
|
|
|
c8bceb |
+ meta l4proto sctp mark 0x00000064 dnat to [[fd00:dead:beef:ff0::]:66]
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ }
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IPTABLES_LIST_RULES([nat], [PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
+ IP6TABLES_LIST_RULES([nat], [PRE_public_allow], 0, [dnl
|
|
|
c8bceb |
+ DNAT sctp ::/0 ::/0 mark match 0x64 [to:[fd00:dead:beef:ff0::]:66]
|
|
|
c8bceb |
+ ])
|
|
|
c8bceb |
FWD_CHECK([--query-forward-port port=66:proto=sctp:toport=66:toaddr=fd00:dead:beef:ff0:: --zone=public], 0, ignore)
|
|
|
c8bceb |
FWD_CHECK([--remove-forward-port=port=66:proto=sctp:toport=66:toaddr=fd00:dead:beef:ff0::], 0, ignore)
|
|
|
c8bceb |
FWD_CHECK([--query-forward-port=port=66:proto=sctp:toport=66:toaddr=fd00:dead:beef:ff0::], 1, ignore)
|
|
|
c8bceb |
--
|
|
|
c8bceb |
2.20.1
|
|
|
c8bceb |
|