Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
different iptables rules in config file and $ipbables -L
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
linderox
n00b
n00b


Joined: 03 Jun 2007
Posts: 41

PostPosted: Fri Nov 23, 2007 9:55 am    Post subject: different iptables rules in config file and $ipbables -L Reply with quote

I have Gentoo router.there is a problem that i don't know where to find config file for my iptables, i know some places,but
all tables in this configs have no any similarity with a comand iptables -L

I found several files
/etc/init.d/iptables #run script

/etc/conf.d/iptbales # here there is a line
IPTABLES_SAVE="/var/lib/iptables/rules-save"

/var/lib/iptables/rules-save
Code:

# Generated by iptables-save v1.2.11 on Tue May 10 08:06:58 20ccept all from localhost
-A INPUT -s 127.0.0.1 -j ACCEPT

# accept all previously established connections
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p UDP -m state --state RELATED,ESTABLISHED -j ACCEPT

# ssh
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

# ftp / webserver related
-A INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5190 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dpoer 110 -j ACCEPT
# Windows / Samba
-A INPUT -p tcp -m state --state NEW -m tcp --dport 137:139 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 426 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT

# up to 5 Bit-torrent connections
-A INPUT -p tcp -m state --state NEW -m tcp --dport 6881:6886 -j ACCEPT

# reject everything else
-A INPUT -j REJECT --reject-with icmp-port-unreachable

COMMIT


here is a comand
Code:

$iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh

Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  10.0.3.0/24          anywhere            tcp dpt:20003
ACCEPT     all  --  server.vodoline.loc  anywhere
ACCEPT     all  --  10.0.3.3             anywhere
ACCEPT     all  --  anywhere             10.0.3.0/24         state RELATED,ESTABLISHED
ACCEPT     icmp --  10.0.3.0/24          anywhere
ACCEPT     tcp  --  10.0.3.0/24          anywhere            tcp dpt:https
ACCEPT     tcp  --  10.0.3.0/24          anywhere            tcp dpt:aol

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
$iptables -L

another one
Code:

$rc-update -s | grep ipt
                iptables |
Back to top
View user's profile Send private message
Sadako
Advocate
Advocate


Joined: 05 Aug 2004
Posts: 3792
Location: sleeping in the bathtub

PostPosted: Fri Nov 23, 2007 10:24 am    Post subject: Reply with quote

Simply use iptable-save rather than iptables -L to get the rules that would be used in a config file.
_________________
"You have to invite me in"
Back to top
View user's profile Send private message
linderox
n00b
n00b


Joined: 03 Jun 2007
Posts: 41

PostPosted: Fri Nov 23, 2007 10:29 am    Post subject: Reply with quote

read topic more attentivly!
I know that it is easy... and i want to use this way,but how if run script doesn't use this file
I told that in rules-save rules different then now is working!
and i dont know where to find file to edit rules! Look higher!!!!
Back to top
View user's profile Send private message
Sadako
Advocate
Advocate


Joined: 05 Aug 2004
Posts: 3792
Location: sleeping in the bathtub

PostPosted: Fri Nov 23, 2007 10:49 am    Post subject: Reply with quote

I'm still not sure what you're problem is, so I'll try to describe how it works.

/etc/init.d/iptables is the script which starts and stops iptables (basically loads or flushes the rules).

/etc/conf.d/iptables is the file which stores certain variables used by the script in init.d, including which file to store the rules in (IPTABLES_SAVE).

This is what I think you are failing to grasp; all the configuaration files in /etc/conf.d are automatically sourced by the corresponding scripts in /etc/init.d.

The best way to manipulate this is to add or remove the rules you want manually, via `iptables -A` or whatever, and then running `/etc/init.d/iptables save` will save them to the IPTABLES_SAVE file for you.

You can of course edit the IPTABLES_SAVE file manually too.
_________________
"You have to invite me in"
Back to top
View user's profile Send private message
Dagger
Retired Dev
Retired Dev


Joined: 11 Jun 2003
Posts: 765
Location: UK

PostPosted: Fri Nov 23, 2007 2:23 pm    Post subject: Reply with quote

from what I can see there you have 2 different sets of rules. One was created my /etc/ini.d/iptables save and it's located in /var/lib/iptables/rules-save (and it is NOT in use now) and the other one had to be added manually or initiated by external script (which IS loaded - you can see it with iptables -L).

I would check rc-update show to check what is starting automatically and check /etc/conf.d/local.start

btw
using !!! and rude answers are not the best way to treat people who are trying to help you...
_________________
95% of all computer errors occur between chair and keyboard (TM)
Join the FSF as an Associate Member!
Post under CC license.
Back to top
View user's profile Send private message
linderox
n00b
n00b


Joined: 03 Jun 2007
Posts: 41

PostPosted: Fri Nov 23, 2007 6:35 pm    Post subject: Reply with quote

I know that there are 2 ways to add rule.
But when system starting after restarting they taking rules from some other place and i want to know from which, cause when i'm editing IPTABLES_SAVE it doesn't work aftrer reboot!

there are no anything inside /etc/conf.d/local.start and local.stop
Back to top
View user's profile Send private message
Dagger
Retired Dev
Retired Dev


Joined: 11 Jun 2003
Posts: 765
Location: UK

PostPosted: Sat Nov 24, 2007 12:00 pm    Post subject: Reply with quote

please post your rc-update show
_________________
95% of all computer errors occur between chair and keyboard (TM)
Join the FSF as an Associate Member!
Post under CC license.
Back to top
View user's profile Send private message
linderox
n00b
n00b


Joined: 03 Jun 2007
Posts: 41

PostPosted: Mon Nov 26, 2007 8:02 am    Post subject: Reply with quote

Thank you for everybody! The place was there:
/etc/runlevels/default/fwsetup
There is a link to a firewall script!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum