LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-20-2005, 09:44 AM   #1
andra
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Rep: Reputation: 0
problem with my first firewall....


i want to make my first firewall )

what's wrong becouse when i run it, the internet connection goes down (sorry for my english)

#!/bin/sh

modprobe ip_tables
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ip_conntrack_irc
modprobe ip_nat_irc

iptables=/usr/sbin/iptables

$iptables -P INPUT DROP
$iptables -P OUTPUT DROP
$iptables -P FORWARD DROP

$iptables -F INPUT
$iptables -F OUTPUT
$iptables -F FORWARD

$iptables -A INPUT -i lo -j ACCEPT
$iptables -A OUTPUT -o lo -j ACCEPT

#$iptables -A INPUT -i eth1 -s 192.168.0.1/24 -j ACCEPT

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

$iptables -A INPUT -p TCP -i eth0 -s 0/0 --destination-port 22 -j ACCEPT
$iptables -A INPUT -p TCP -i eth0 -s 0/0 --destination-port 80 -j ACCEPT
$iptables -A INPUT -p TCP -i eth0 -s 0/0 --destination-port 21 -j ACCEPT
$iptables -A INPUT -p TCP -i eth0 -s 0/0 --destination-port 53 -j ACCEPT

$iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

$iptables -A INPUT -p TCP ! --syn -m state --state NEW -j LOG --log-prefix "Possbile syn scan"
$iptables -A INPUT -p TCP ! --syn -m state --state NEW -j DROP

thanks
 
Old 09-20-2005, 10:04 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Is this supposed to be a firewall for just a single PC, or for a network?

If for a network, you're not allowing any connections on the FORWARD chain, so no packets will be permitted from the LAN to the NET.
 
Old 09-20-2005, 10:06 AM   #3
andra
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Matir
Is this supposed to be a firewall for just a single PC, or for a network?

If for a network, you're not allowing any connections on the FORWARD chain, so no packets will be permitted from the LAN to the NET.
first for single PC ... then for a network...
 
Old 09-20-2005, 10:08 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Well, for a network, it's horribly lacking.

For local, you're not ACCEPTing any (initial) packets on the OUTPUT chain. You'll need to allow outbound traffic to get any response back.
 
Old 09-20-2005, 10:14 AM   #5
andra
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
...

Last edited by andra; 09-20-2005 at 10:16 AM.
 
Old 09-20-2005, 10:15 AM   #6
andra
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Matir
Well, for a network, it's horribly lacking.

For local, you're not ACCEPTing any (initial) packets on the OUTPUT chain. You'll need to allow outbound traffic to get any response back.
hm... ok
u can give me a firewall? for sigle pc, and then i will learn how to make it for network
 
Old 09-20-2005, 10:17 AM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Assuming no services are being run, and I'm only trying to protect against external attacks, I would do something like:
Code:
#!/bin/bash

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Suit to taste.
 
  


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
Firewall problem Pedroski Linux - Security 2 06-27-2004 10:37 PM
firewall problem..I think SchoolITguy Linux - Software 15 11-04-2003 06:43 AM
rc.firewall-2.4 Problem LucaDanzi Linux - Networking 4 08-08-2003 04:15 PM
Problem with FireWall??? please help! latehit Linux - Security 1 12-14-2002 03:27 PM
Problem Firewall ... ?! dancindoc Linux - Networking 1 02-11-2002 04:02 PM

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

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