LinuxQuestions.org
Visit Jeremy's Blog.
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 09-10-2005, 11:40 AM   #1
ujotne
LQ Newbie
 
Registered: Sep 2003
Posts: 13

Rep: Reputation: 0
iptables on Debian


1) How does one manually start/stop iptables on Debian 3.1 sarge?
What I am after is something like "/service iptables start" on Mandrake.

2) Which TCP port do I need to open to allow APT to fetch packetc vua ftp?
 
Old 09-10-2005, 12:00 PM   #2
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Re: iptables on Debian

Quote:
Originally posted by ujotne
1) How does one manually start/stop iptables on Debian 3.1 sarge?
What I am after is something like "/service iptables start" on Mandrake.

2) Which TCP port do I need to open to allow APT to fetch packetc vua ftp?
1) The general idea in Debian is that you either write your own script that uses iptables or install one of the packages that do it for you like Guarddog, Bastille or Firestarter among others.

2) None you should be able to access a ftp site without opening any ports. Are you behind some kind of proxy server?
 
Old 09-10-2005, 12:42 PM   #3
ujotne
LQ Newbie
 
Registered: Sep 2003
Posts: 13

Original Poster
Rep: Reputation: 0
Re: Re: iptables on Debian

Quote:
Originally posted by HappyTux
1) The general idea in Debian is that you either write your own script that uses iptables or install one of the packages that do it for you like Guarddog, Bastille or Firestarter among others.
I have written my own script and it is very useful to be able to manually start and stop iptables for debygging purposes.

Quote:
[i]
2) None you should be able to access a ftp site without opening any ports. Are you behind some kind of proxy server? [/B]
Obviously I have to open either port 20 or 21 to allow ftp trafic. What I am not sure about is whether apt uses active or passive ftp.
 
Old 09-10-2005, 01:03 PM   #4
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Re: Re: Re: iptables on Debian

Quote:
Originally posted by ujotne
I have written my own script and it is very useful to be able to manually start and stop iptables for debygging purposes.


Well do you have start, stop, restart sections in your script that actually does the proper things when shutting down/starting/restarting iptables to make sure everything gets reset correctly? If so then you should be able to put the script in the /etc/init.d/ directory then use update-rc.d name_of_script defaults and it will create links for the script to be started and stopped in the proper directories. Then to start you would /etc/init.d/name_of_script start of course to stop you would put that on the end of the command.

Quote:
Obviously I have to open either port 20 or 21 to allow ftp trafic. What I am not sure about is whether apt uses active or passive ftp.
No you do not that is only if you want to allow ftp traffic into your server you would be looking for if I recall correctly loading the ip_conntrack_ftp module of iptables to allow for connection tracking when going through the firewall of course making sure that you have enabled the NAT and ip forwarding if needed as well.
 
Old 09-16-2005, 07:36 PM   #5
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
There is a script /etc/init.d/skeleton which you can use as a template to make SysV init scripts. I use this one to run my firewall script. Put the firewall script in /etc/rc.firewall. You may need to edit some paths to fit your system.

Code:
#! /bin/sh

#
#    This file should be  placed in /etc/init.d.
#
#
#

set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="Use this script to start /etc/rc.firewall script"

if [ ! -f /etc/rc.firewall ]; then
  echo "Unable to start iptables firewall - /etc/rc.firewall does not exist"
  exit 1
fi
if [ ! -f /sbin/iptables ]; then
  echo "Cannot find  /sbin/iptables"
  exit 1
fi

case "$1" in
  restart|reload)
        echo "Restarting iptables firewall..."
        $0 stop
        /bin/bash /etc/rc.firewall
        ;;
  start)
        echo  "Setting up iptables firewall..."
        /bin/bash /etc/rc.firewall
        ;;
  stop)
        echo -n "Stopping iptables firewall..."
        iptables -P OUTPUT ACCEPT
        iptables -P INPUT ACCEPT
        iptables -P FORWARD ACCEPT
        iptables -F
        iptables -X
        echo "done."
        exit 0;
        ;;
  panic)
        echo -n "Closing all ports..."
        iptables -P OUTPUT DROP
        iptables -P INPUT DROP
        iptables -P FORWARD DROP
        iptables -F
        iptables -X
        echo "done."
        exit 0;
        ;;
  *)
        echo "Usage: $0  {start|stop|restart|reload|panic}" >&2
        exit 1
        ;;
esac

exit 0
Once you put the script in /etc/init.d you can use the SysV-Init Editor to make it run in the desired run levels.

Last edited by /bin/bash; 09-16-2005 at 07:57 PM.
 
  


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
Debian iptables kingcomein Debian 4 10-31-2005 10:17 PM
Debian iptables kingcomein Linux - Networking 6 10-26-2005 06:20 AM
Debian - IPTABLES czezz Linux - Security 6 06-20-2005 05:07 AM
IPtables - Debian set up fredg Linux - Security 4 05-26-2005 05:04 PM
debian and iptables? banana2 Linux - Security 5 01-12-2003 09:35 AM

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

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