LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-12-2005, 02:51 AM   #1
freakin'me
Member
 
Registered: Aug 2005
Distribution: Debian Sarge
Posts: 31

Rep: Reputation: 15
Location iptables config file


Hi,

I just installed debian, and want to configure iptables. Where can I find the configuratio file?

Regards,

Freakin'me
 
Old 08-12-2005, 02:54 AM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
I do not think that Debian has one itself. You can make your own script and put it into the rc.d-folder to make it start on boot.
 
Old 08-12-2005, 02:57 AM   #3
freakin'me
Member
 
Registered: Aug 2005
Distribution: Debian Sarge
Posts: 31

Original Poster
Rep: Reputation: 15
I suppose you mean /etc/rc.d/ but that's exactly the tricky thing, I don't have that dir. I do have rc0.d up to rc6.d so I still do not know which one I should have.

I installed iptables using apt-get, maybe that does matter?
 
Old 08-12-2005, 03:20 AM   #4
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
Yes, debian has rcX.d

The number X stands for different runlevels. You should put your script in init.d and then make a symlink to the rcX.d for which runlevel you want your script to run at.

Here's a good guide on the subject: http://www.tldp.org/HOWTO/From-Power...t-HOWTO-6.html

EDIT: via apt-get? I thought iptables came with Debian by default. Anyway, it should not matter. As long as you can handle iptables you will be fine making your own script.

If you are having troubles remembering everything you can always check the man pages. if you do not want to write your own iptables script you can google for some examples.

Last edited by Ephracis; 08-12-2005 at 03:23 AM.
 
Old 08-12-2005, 03:35 AM   #5
freakin'me
Member
 
Registered: Aug 2005
Distribution: Debian Sarge
Posts: 31

Original Poster
Rep: Reputation: 15
If I put that script in init.d, how does iptables know that it is intended for iptables?

For me being a linux noob, I've got one question left, how do I make an symlink?

Thanks for your help.
 
Old 08-12-2005, 03:54 AM   #6
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
Quote:
If I put that script in init.d, how does iptables know that it is intended for iptables?
The script is actually a shell script, it just issues some iptables commands.

Quote:
For me being a linux noob, I've got one question left, how do I make an symlink?
ln -s /from/where /to/destination
man ln for more info.

EDIT:
Here you have my script:
Code:
#!/bin/sh

# flush the tables
iptables -F
iptables -Z

# drop everything by default
iptables -P INPUT DROP


# EXTERNAL

# ssh
iptables -A INPUT -s 0/0 -p tcp --dport 841 -j ACCEPT
# msn
iptables -A INPUT -s 0/0 -p tcp --dport 6891:6900 -j ACCEPT
# torrent
iptables -A INPUT -s 0/0 -p tcp --dport 6881:6889 -j ACCEPT
iptables -A INPUT -s 0/0 -p udp --dport 6881:6889 -j ACCEPT


# LOCAL

# kismet
iptables -A INPUT -i lo -p tcp --dport 2501 -j ACCEPT
# mysql
iptables -A INPUT -i lo -p tcp --dport 3306 -j ACCEPT


# accept already established connections
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

Last edited by Ephracis; 08-12-2005 at 03:58 AM.
 
Old 08-12-2005, 05:43 AM   #7
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Save yourself alot of time:

apt-get install guarddog

FYI, in debian all the startup scripts are located in /etc/init.d. The directories /etc/rc?.d are runlevel directories which contain symlinks to the scripts in /etc/init.d. The symlink will cause the script to start or stop depending on weather the symlink starts with an S or a K, e.g.
/etc/rc3.d/S20guarddog -> ../init.d/guarddog
The above symlink would cause guarddog to start when you enter runlevel 3 (/sbin/init 3.)
/etc/rc0.d/K20guarddog -> ../init.d/guarddog
If you do a shutdown the above symlink would cause guarddog to stop, the K stands for kill.

If you have an iptables script you really want to use, go ahead and install guarddog then put your iptables script here:
/etc/rc.firewall
Make sure it's executable. Then guarddog will start your script instead of its own.
 
Old 08-13-2005, 02:26 PM   #8
DarkNeo
Member
 
Registered: Aug 2005
Location: Rome
Distribution: Slackware 10.2 && Debian Sarge
Posts: 49

Rep: Reputation: 15
Why you must use a firewall for the normal pc the firewall is unuseful try to close the service by #.
If you are sure to use the firewall in slackware you must created one file "rc.firewall" chmod 755 in /etc/rc.d/ and here u can put all rules.
ByE
 
Old 08-14-2005, 07:30 AM   #9
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
An alternative using a full script is simply call
Code:
iptables-save > /path/to/save
to save your current rules to disk, then at boot simply execute
Code:
iptables-restore < /path/to/save
That way, if you make any adjustments to your filtering rules, you simply execute iptables-save again to update your saved ruleset, and the new rules will be loaded at next boot.
 
Old 08-14-2005, 07:57 AM   #10
harken
Member
 
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
Quote:
Originally posted by DarkNeo
Why you must use a firewall for the normal pc the firewall is unuseful
Yeah, sure...you can't be serious, right?
Quote:
Originally posted by freakin'me
If I put that script in init.d, how does iptables know that it is intended for iptables?
When the computer enters one of the runlevels which correspond to a certain rcX.d, it will read, line by line, and execute the scripts having an 'S' at the beginning of their name. And while the script contains commands that invoke /sbin/iptables, it's all taken care of.

Last edited by harken; 08-14-2005 at 08:01 AM.
 
Old 08-14-2005, 08:01 AM   #11
freakin'me
Member
 
Registered: Aug 2005
Distribution: Debian Sarge
Posts: 31

Original Poster
Rep: Reputation: 15
I've planned to use my server as a gateway as well, and I can't do anything about it, but then you need to configure some sort of firewall.........
 
  


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
config file with icon location KDE? slug420 Linux - General 2 05-23-2005 07:48 AM
MBR location specified in kickstart config file owenh Linux - General 2 03-22-2005 05:06 PM
where is the iptables dufault rules config file? ayiiq180 Linux - Software 2 12-18-2004 02:42 AM
Config file organization/location Dark_Helmet Linux - General 2 05-24-2004 10:41 AM
location of iptables config file munisp Linux - Networking 1 12-13-2001 06:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:02 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