Skip to contentSkip to conversation

Fix error in example firewall.sh script

PATCH In review Frank Lichtenheld 5 participants 7 messages Nov 7, 2021 – Nov 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix error in example firewall.sh script

From: Adrian <[email protected]...>

The man page says:
[!] -s, --source address[/mask][,...]

---
 sample/sample-config-files/firewall.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

As part of an initative to clean up the Github PR submissions, submitting this patch to the mailing list for inclusion. Looks obviously correct to me.

sample/sample-config-files/firewall.sh +1 -1
index 19d75ee9..456700ca 100755
@@ -50,7 +50,7 @@ iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP
 iptables -A OUTPUT -p udp --sport 137:139 -o eth0 -j DROP
 
 # Check source address validity on packets going out to internet
-iptables -A FORWARD -s ! $PRIVATE -i eth1 -j DROP
+iptables -A FORWARD ! -s $PRIVATE -i eth1 -j DROP
 
 # Allow local loopback
 iptables -A INPUT -s $LOOP -j ACCEPT
Signature · 1 line
2.30.2
#1 lore raw

Am 07.11.21 um 18:40 schrieb Frank Lichtenheld:

Quoted 20 lines

From: Adrian <[email protected]...>

The man page says:
[!] -s, --source address[/mask][,...]

---
  sample/sample-config-files/firewall.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

As part of an initative to clean up the Github PR submissions, submitting this patch to the mailing list for inclusion. Looks obviously correct to me.

sample/sample-config-files/firewall.sh +0 -0
index 19d75ee9..456700ca 100755

sample/sample-config-files/firewall.sh iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP · line 56

Quoted 8 lines
sample/sample-config-files/firewall.sh +1 -1
@@ -50,7 +50,7 @@ iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP
  iptables -A OUTPUT -p udp --sport 137:139 -o eth0 -j DROP
 
  # Check source address validity on packets going out to internet
-iptables -A FORWARD -s ! $PRIVATE -i eth1 -j DROP
+iptables -A FORWARD ! -s $PRIVATE -i eth1 -j DROP
 
  # Allow local loopback
  iptables -A INPUT -s $LOOP -j ACCEPT

I have a vague idea that this is actually different. Like one is that condition is not fulfilled and the other is that it is not part of the subnet if is different when there is different protocol but I might misremember.

Arne

#2 lore raw
Quoted 30 lines

Arne Schwabe <[email protected]...> hat am 08.11.2021 12:36 geschrieben:

Am 07.11.21 um 18:40 schrieb Frank Lichtenheld:

Quoted 25 lines

From: Adrian <[email protected]...>

The man page says:
[!] -s, --source address[/mask][,...]

---
  sample/sample-config-files/firewall.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

As part of an initative to clean up the Github PR submissions, submitting this patch to the mailing list for inclusion. Looks obviously correct to me.

sample/sample-config-files/firewall.sh +1 -1
index 19d75ee9..456700ca 100755
@@ -50,7 +50,7 @@ iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP
  iptables -A OUTPUT -p udp --sport 137:139 -o eth0 -j DROP
 
  # Check source address validity on packets going out to internet
-iptables -A FORWARD -s ! $PRIVATE -i eth1 -j DROP
+iptables -A FORWARD ! -s $PRIVATE -i eth1 -j DROP
 
Quoted 9 lines

sample/sample-config-files/firewall.sh iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP · line 56

Quoted 3 lines
sample/sample-config-files/firewall.sh +0 -0
  # Allow local loopback
  iptables -A INPUT -s $LOOP -j ACCEPT

I have a vague idea that this is actually different. Like one is that condition is not fulfilled and the other is that it is not part of the subnet if is different when there is different protocol but I might misremember.

Certainly does not work with my iptables:

# iptables -A OUTPUT -s ! 10.0.0.0/8 -j ACCEPT
Bad argument `10.0.0.0/8'
Try `iptables -h' or 'iptables --help' for more information.
# iptables -A OUTPUT ! -s 10.0.0.0/8 -j ACCEPT
#

Regards,
Frank

#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 57 lines · Frank Lichtenheld
Quoted 49 lines

Arne Schwabe [email protected]... hat am 08.11.2021 12:36 geschrieben:

Am 07.11.21 um 18:40 schrieb Frank Lichtenheld:

Quoted 38 lines

From: Adrian [email protected]...

The man page says:

[!] -s, --source address[/mask][,...]

------------------------------------------------------

sample/sample-config-files/firewall.sh | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

As part of an initative to clean up the Github PR submissions, submitting

this patch to the mailing list for inclusion. Looks obviously correct to

me.

sample/sample-config-files/firewall.sh +0 -0

index 19d75ee9..456700ca 100755

--- a/sample/sample-config-files/firewall.sh

+++ b/sample/sample-config-files/firewall.sh

sample/sample-config-files/firewall.sh +0 -0
@@ -50,7 +50,7 @@ iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP
 

iptables -A OUTPUT -p udp --sport 137:139 -o eth0 -j DROP

Check source address validity on packets going out to internet
==============================================================

sample/sample-config-files/firewall.sh +1 -1
-iptables -A FORWARD -s ! $PRIVATE -i eth1 -j DROP
 
+iptables -A FORWARD ! -s $PRIVATE -i eth1 -j DROP
Quoted 4 lines

Allow local loopback
====================

iptables -A INPUT -s $LOOP -j ACCEPT

I have a vague idea that this is actually different. Like one is that

Quoted 5 lines

condition is not fulfilled and the other is that it is not part of the

subnet if is different when there is different protocol but I might

misremember.

Certainly does not work with my iptables:

Quoted 8 lines

iptables -A OUTPUT -s ! 10.0.0.0/8 -j ACCEPT
============================================

Bad argument 10.0.0.0/8' Try iptables -h' or 'iptables --help' for more information.

iptables -A OUTPUT ! -s 10.0.0.0/8 -j ACCEPT
============================================

From: https://ipset.netfilter.org/iptables.man.html

[!] -s, --source address[/mask][,...]
Source specification. Address can be either a network name, a hostname, a network IP address (with /mask), or a plain IP address. Hostnames will be resolved once only, before the rule is submitted to the kernel. Please note that specifying any name to be resolved with a remote query such as DNS is a really bad idea. The mask can be either an ipv4 network mask (for iptables) or a plain number, specifying the number of 1's at the left side of the network mask. Thus, an iptables mask of 24 is equivalent to 255.255.255.0. A "!" argument before the address specification inverts the sense of the address. The flag --src is an alias for this option. Multiple addresses can be specified, but this will expand to multiple rules (when adding with -A), or will cause multiple rules to be deleted (with -D).

R
-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wsBzBAEBCAAGBQJhiSw2ACEJEE+XnPZrkLidFiEECbw9RGejjXJ5xVVVT5ec 9muQuJ1jZAf/b2mzU/9kXQIIvNAhICrkyDc68AnyR5GRlMItdo91prqcH/bn ksBxh5OolZeq7Md7K6O63DZgL3Kdj0HpUGavPonVgIrBXj1QoQW69KiEp9/A 98UixypgCCi3yy4wii510Wn9F8ZFmfQBk9l/ilRB5tT+oU6/KyvaZmwz2kRQ pkmcvXWI40LEvjMXA1Ye5Usn7a1yf5lP2YbJyvhE8mG64mZo6/2fePyTuASd EhCzxoQ1QIUy/jHL6FCHac6Gt2lx5JH73CI9lKzczvfZmq4Y7a3I5+rjpP2w Gx4YdA/PkRK5QJtn/KHppCZx4FdYBSvW2Aqq+fSrhzPam//qXQLt6g== =8IIR
-----END PGP SIGNATURE-----

#4 lore raw
In reply to Frank Lichtenheld
Quoted 41 lines · Frank Lichtenheld
Quoted 30 lines

Arne Schwabe <[email protected]...> hat am 08.11.2021 12:36 geschrieben:

Am 07.11.21 um 18:40 schrieb Frank Lichtenheld:

Quoted 25 lines

From: Adrian <[email protected]...>

The man page says:
[!] -s, --source address[/mask][,...]

---
   sample/sample-config-files/firewall.sh | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

As part of an initative to clean up the Github PR submissions, submitting this patch to the mailing list for inclusion. Looks obviously correct to me.

sample/sample-config-files/firewall.sh +1 -1
index 19d75ee9..456700ca 100755
@@ -50,7 +50,7 @@ iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP
   iptables -A OUTPUT -p udp --sport 137:139 -o eth0 -j DROP
 
   # Check source address validity on packets going out to internet
-iptables -A FORWARD -s ! $PRIVATE -i eth1 -j DROP
+iptables -A FORWARD ! -s $PRIVATE -i eth1 -j DROP
 
Quoted 9 lines

sample/sample-config-files/firewall.sh iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP · line 56

Quoted 3 lines
sample/sample-config-files/firewall.sh +0 -0
   # Allow local loopback
   iptables -A INPUT -s $LOOP -j ACCEPT

I have a vague idea that this is actually different. Like one is that condition is not fulfilled and the other is that it is not part of the subnet if is different when there is different protocol but I might misremember.

Certainly does not work with my iptables:

Quoted 8 lines
# iptables -A OUTPUT -s ! 10.0.0.0/8 -j ACCEPT
Bad argument `10.0.0.0/8'
Try `iptables -h' or 'iptables --help' for more information.
# iptables -A OUTPUT ! -s 10.0.0.0/8 -j ACCEPT
#

Regards,
Frank

I remember iptables announced it would redo the parsing logic for the command line interfaces ages ago, where the negation needed to happen before the "rule parameter" (-s in this case). It's probably closer to 8-10 years since this change, unless my memory is completely corrupted.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
Acked-by on v1 1/1
#5 lore raw
In reply to Frank Lichtenheld
Quoted 20 lines · Frank Lichtenheld

From: Adrian <[email protected]...>

The man page says:
[!] -s, --source address[/mask][,...]

---
  sample/sample-config-files/firewall.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

As part of an initative to clean up the Github PR submissions, submitting this patch to the mailing list for inclusion. Looks obviously correct to me.

sample/sample-config-files/firewall.sh +0 -0
index 19d75ee9..456700ca 100755

sample/sample-config-files/firewall.sh iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP · line 56

Quoted 8 lines
sample/sample-config-files/firewall.sh +1 -1
@@ -50,7 +50,7 @@ iptables -A OUTPUT -p tcp --sport 137:139 -o eth0 -j DROP
  iptables -A OUTPUT -p udp --sport 137:139 -o eth0 -j DROP
 
  # Check source address validity on packets going out to internet
-iptables -A FORWARD -s ! $PRIVATE -i eth1 -j DROP
+iptables -A FORWARD ! -s $PRIVATE -i eth1 -j DROP
 
  # Allow local loopback
  iptables -A INPUT -s $LOOP -j ACCEPT

This change makes sense to me. The syntax changed ages ago for iptables, where the negation needed to happen first.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#6 lore raw
In reply to Frank Lichtenheld

Your patch has been applied to the master and release/2.5 branch (bugfix).

Thanks!

commit d720c5fd45d5c61b9c797172f8d6a7eaa35b959c (master) commit 6b2c423aa42a11b41f90aad8f53db71703cee2e2 (release/2.5)

Author: Adrian
Date:   Sun Nov 7 18:40:00 2021 +0100
     Fix error in example firewall.sh script

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: David Sommerseth <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg23128.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering