Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negation of one object must be declared before the qualification of the address - iptables-1.4.21 #17

Open
carlxvier opened this issue May 9, 2016 · 0 comments

Comments

@carlxvier
Copy link

carlxvier commented May 9, 2016

Hi.
The Linux compiler has to be changed in order to be compatible with the sintax restriction arised with the new iptables.
Rules like this
screenshot_20160509_164509

Are going to be compiled this way:
`
$IPTABLES -A OUTPUT -p tcp -m tcp -s ! 192.0.2.2 --dport 22 -j RULE_1
$IPTABLES -A INPUT -p tcp -m tcp -s ! 192.0.2.2 --dport 22 -j RULE_1
$IPTABLES -A FORWARD -p tcp -m tcp -s ! 192.0.2.2 --dport 22 -j RULE_1

$IPTABLES -A INPUT -p tcp -m tcp -s 192.0.2.2 -d ! 10.10.0.10 --dport 23 -j RULE_2
$IPTABLES -A FORWARD -p tcp -m tcp -s 192.0.2.2 -d ! 10.10.0.10 --dport 23 -j RULE_2
`

This sintax isn't accepted by the new iptables anymore, it now needs do be stated like:
`
$IPTABLES -A OUTPUT -p tcp -m tcp ! -s 192.0.2.2 --dport 22 -j RULE_1
$IPTABLES -A INPUT -p tcp -m tcp ! -s 192.0.2.2 --dport 22 -j RULE_1
$IPTABLES -A FORWARD -p tcp -m tcp ! -s 192.0.2.2 --dport 22 -j RULE_1

$IPTABLES -A INPUT -p tcp -m tcp -s 192.0.2.2 ! -d 10.10.0.10 --dport 23 -j RULE_2
$IPTABLES -A FORWARD -p tcp -m tcp -s 192.0.2.2 ! -d 10.10.0.10 --dport 23 -j RULE_2
`

I managed to fix the generated script by parsing it through this sed command:
sed '{s/\-s \!/\! \-s/g;s/\-d \!/\! \-d/g;}' firewal.script

This is back compatible with old iptables version (tested with version 1.3.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant