LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 11-24-2006, 05:55 PM   #1
Linuxfrog
Member
 
Registered: Jan 2004
Location: Dallas
Distribution: Debian 4.0, Centos and Fedora
Posts: 30

Rep: Reputation: 15
Noob Admin, security concerns


I have been getting a little frustrated with trying to setup iptables firewall rules for my new webserver. I am new at this and basically need only a few services accessible, this is a public webserver that is going to be pounded on alot, I am working through ssh only so I have been looking for a script. A few of my challenges are this, I am running multiple sites as I am hosting, I need ssh, ftp, mail, and http - https services available. The thing is I have read through iptables setups, but I am used to hardware firewall, so the difference is alot haha. I see alot of scripts online for office firewalls but havent found much for webservers. If you guys have any suggestions besides google LoL I would be much appreciative, Thanks, Frog
 
Old 11-24-2006, 06:21 PM   #2
hob
Senior Member
 
Registered: Mar 2004
Location: Wales, UK
Distribution: Debian, Ubuntu
Posts: 1,075

Rep: Reputation: 45
IPTables has a lot of options, but you can ignore most of them. Feeding this in with iptables-restore provides a basic configuration with SSH, HTTP and HTTPS access, and you can add ports just by specifying extra lines for the relevant port numbers:

*filter
# Set the default policies: ACCEPT outbound connections, and DROP all others
:INPUT DROP [3342:147048]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [526:34970]
# Accept anything from the loopback interface
-A INPUT -i lo -j ACCEPT
# Accept responses to connections that this system initiated
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# Accept pings
-A INPUT -i eth0 -p icmp -j ACCEPT
# Accept SSH connections
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
# Accept HTTP connections
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
# Accept HTTPS connections
-A INPUT -i eth0 -p tcp -m tcp --dport 443 -j ACCEPT
COMMIT
 
Old 11-25-2006, 09:25 PM   #3
Linuxfrog
Member
 
Registered: Jan 2004
Location: Dallas
Distribution: Debian 4.0, Centos and Fedora
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks

I appreciate the info , however is the a configuration setup for a .conf file, or commands I enter in to bash?
 
Old 11-26-2006, 03:23 AM   #4
hob
Senior Member
 
Registered: Mar 2004
Location: Wales, UK
Distribution: Debian, Ubuntu
Posts: 1,075

Rep: Reputation: 45
Put your firewall rules in a text file (e.g. /etc/network/firewall-rules), and use the iptables-restore utility to load the rules in:

iptables-restore < /etc/network/firewall-rules

On Debian I automate loading the firewall by adding this script to the directory /etc/network/if-pre-up.d/:

#!/bin/bash -e

### ** Enable IPv4 Firewall **
###
### Borrowed from "The Debian System" by Martin Krafft
###
### Important: iptables only filters IPv4 traffic
### Important: To filter IPv6 traffic , use ip6tables

# Exit if the interface is loopback
[[$IFACE=lo]] || exit 0

# Input the rules from the file /etc/network/firewall-rules
exec iptables-restore < /etc/network/firewall-rules

# End of script

Hope that helps.
 
Old 11-26-2006, 03:29 AM   #5
hob
Senior Member
 
Registered: Mar 2004
Location: Wales, UK
Distribution: Debian, Ubuntu
Posts: 1,075

Rep: Reputation: 45
If you are using Sarge you may need to replace the "conntrack" rule on the example that I posted with this line:

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

(Sarge uses a 2.4 kernel, rather than the standard 2.6).
 
  


Reply

Tags
debian, firewall, iptables



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
Linux newbie, I don't understand sys. admin. or security. StoneAgeMoron Linux - Security 8 03-26-2006 11:02 AM
Noob security advice Fiend Linux - Security 3 08-28-2004 08:46 PM
MRTG: security concerns? registering Linux - Security 2 08-07-2003 06:56 AM
Linux Admin/Security/LAMPS/Develop Books jonconley Linux - Newbie 1 04-29-2003 02:28 PM
Security Breach Traced to Hole in Head of Admin unSpawn General 3 05-30-2001 06:32 PM

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

All times are GMT -5. The time now is 02:30 PM.

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