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 - 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 01-10-2004, 10:26 AM   #1
RTT
Member
 
Registered: Nov 2003
Location: England
Distribution: slackware, FreeBSD
Posts: 33

Rep: Reputation: 15
iptables config -


Hi, I've been using this script that I wrote myself for a while but all of a sudden it's stopped working The box refuses to talk to the internet when this is applied.

Code:
#!/bin/sh
#
# rtt's firewall script using IPTABLES
#
# Open ports: 3874, 80, 21
#
IPTABLES="/usr/sbin/iptables"
UPPORTS="1024:65535"
PPORTS="0:1023"
#
# Clear...
$IPTABLES --policy INPUT ACCEPT
$IPTABLES --policy OUTPUT ACCEPT
$IPTABLES --policy FORWARD ACCEPT
$IPTABLES --flush
#
# Start...
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT
$IPTABLES --policy INPUT DROP
$IPTABLES --policy OUTPUT ACCEPT
#
#
# Allow from local network:
$IPTABLES -A INPUT -s 192.168.0.0/24 -i eth0 -j ACCEPT
#
# Open port 80
$IPTABLES -A INPUT -s ! 192.168.0.0/24 -i eth0 -p tcp -m state --state NEW --sport $UPPORTS --dport 80 -j ACCEPT
# Open port 21
$IPTABLES -A INPUT -s ! 192.168.0.0/24 -i eth0 -p tcp -m state --state NEW --sport $UPPORTS --dport 21 -j ACCEPT
# Open 3784
$IPTABLES -A INPUT -s ! 192.168.0.0/24 -i eth0 -p tcp -m state --state NEW --sport $UPPORTS --dport 3784 -j ACCEPT
# Open 6667
$IPTABLES -A INPUT -s 0/0 -i eth0 -p tcp -m state --state NEW --sport $UPPORTS --dport 6667 -j ACCEPT 
# EOF
All it does is allow any traffic on the local network, and then opens up ports 80, 21 and 3784 to anyone.

Any ideas why this locks the box from the internet?

Any help much appreciated!
 
Old 01-10-2004, 10:54 AM   #2
artur
Member
 
Registered: Apr 2002
Location: Illinois, US
Distribution: Red Hat, Fedora, Yellow Dog, Debian, FreeBSD, Embedix
Posts: 106

Rep: Reputation: 15
Re: iptables config -

Quote:
Originally posted by RTT
Code:
# Clear...
$IPTABLES --policy INPUT ACCEPT
#
# Start...
$IPTABLES --policy INPUT DROP
Isn't this redundant? Why set policy to accept just to change it to drop right after it?
Quote:
Code:
# Allow from local network:
$IPTABLES -A INPUT -s 192.168.0.0/24 -i eth0 -j ACCEPT
#
# Open port 80
$IPTABLES -A INPUT -s ! 192.168.0.0/24 -i eth0 -p tcp -m state --state NEW --sport $UPPORTS --dport 80 -j ACCEPT
That -s ! 192.168.0.0/24 part is redundant too, I think. You just let all the traffic from 192.168.0.0/24 through, so you know that it won't be comming from that net to this rule. Why slow down the filter checking for it? Just skip the -s portion.

Generally, your rules seem a bit too restrictive. Loosen up on them and let some more traffic in. Why do you care which port the connection comes from? So what if some machine uses it's port 80 to talk to your port 80?

You could use tcpdump to see what exactly happens when you try to talk to the net and where connection stops.
 
Old 01-10-2004, 02:40 PM   #3
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 69
You'll also need to allow packets that are of the state RELATED,ESTABLISHED. As of right now, your firewall will allow only packets which are NEW and are opening a tcp connection, but there isn't any rule to allow the tcp packets that follow, so they'll fall through and hit the default input policy of DROP. Something like:

iptables -A INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT

should do the trick.
 
  


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
iptables config ? ryanjliles Linux - Networking 2 09-01-2005 04:45 AM
iptables module config swmok Linux - Networking 3 04-17-2005 08:42 AM
iptables config probs geniarse Linux - Networking 4 10-28-2004 12:18 PM
Firestarter or IPTables config? gbg Linux - Networking 2 03-31-2004 06:44 AM
newbie iptables config... christophe.dr Linux - Networking 1 10-08-2003 03:12 PM

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

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