LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 04-14-2021, 12:18 PM   #1
hkjz
Member
 
Registered: Apr 2019
Distribution: MX
Posts: 182

Rep: Reputation: Disabled
Problem with leaks in IPTABLES firewall


Hello,

there is something wrong with the firewall rules i made with IPTABLES

when i load system and load the rules to see them i got this:
Code:
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  217.23.1.184         anywhere            
ACCEPT     all  --  217.23.1.184         anywhere            
DROP       all  --  anywhere             anywhere            
DROP       all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
LOG        all  --  anywhere             anywhere             LOG level warning
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             217.23.1.184        
ACCEPT     all  --  anywhere             217.23.1.184        
DROP       all  --  anywhere             anywhere            
DROP       all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate ESTABLISHED
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere
However, when i reload the firewall rules by hand from file, i am left with this only
Code:
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
LOG        all  --  anywhere             anywhere             LOG level warning
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate ESTABLISHED
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere
to mitigate this problem i even used such a line in crontab
@reboot cd /path/to/file/ && ./iptables_rules_file

but it did not help.


The first part is interesting, part of curiosity, I suspect that all these files are somehow connected to underlying system functions. Should I unlock them?

The second part with iptables is more concerning - especially '217.23.1.184', which is WorldStream B.V., probably a VPN provider. I recognize the name because it sometimes shows up in my VPN as well.

But in the iptables rules it comes out of nowhere,

I will do more tests with cronetab and reboots to let you know the result.
 
Old 04-14-2021, 04:25 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,679
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Since iptables rules can be fairly tricky to get right if you are "riding the pony bareback," I prefer to use higher-level tools such as shorewall, which can automagically write and install proper rules for you. Very definitely easier.

Last edited by sundialsvcs; 04-14-2021 at 04:27 PM.
 
Old 04-15-2021, 11:32 AM   #3
jdrosales
LQ Newbie
 
Registered: Feb 2020
Location: Virginia, USA
Distribution: Ubuntu, Debian
Posts: 21
Blog Entries: 1

Rep: Reputation: 3
Use iptables-save > your_rules.txt (<-- this is just an example, the file can be named anyway you want ) after you update your iptables rules. Then, at boot time (or whenever you need to) use iptables-restore < your_rules.txt

I think that should solve your problem.
 
Old 04-17-2021, 01:58 PM   #4
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
I have a feeling you have a problem. The rules file is not executable, by your script. It always should be "iptables-restore < rules" as someone mentioned.

Second, some distros need the iptables-persistent package. This preloads rules from usually /etc/iptables/? or /etc/sysconfig/?. iptables-restore does not update the rules there, so it might be better to update the rules there THEN reload iptables via whatever script starts iptables, whether /etc/init.d or systemctl or whatever.

So for testing, you certainly can:

iptables-save > RULES
edit RULES to test them
iptables-restore < RULES

But for persistence, you have to update the files in /etc/iptables or /etc/sysconfig to go across reboots if the persistence package is installed "OR you have to create your own startup/init script". I'd install the persistence packages, they work just fine.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why IPTABLES leaks internal IP? zivota Linux - Security 3 08-13-2008 03:25 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
Mandrake 10 Community memory leaks anyone? guddler Mandriva 9 10-06-2004 01:06 AM
Memory Leaks? stampede96 Linux - Software 3 02-20-2003 12:52 PM
Memory Leaks and Processes in Linux... Sonny Programming 10 03-04-2002 05:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration