All of lore.kernel.org
 help / color / mirror / Atom feed
* No Internet Connection
@ 2004-09-10 14:49 Giancarlo Boaron
  2004-09-10 15:33 ` Jason Opperisano
  2004-09-10 16:41 ` Aleksandar Milivojevic
  0 siblings, 2 replies; 14+ messages in thread
From: Giancarlo Boaron @ 2004-09-10 14:49 UTC (permalink / raw)
  To: netfilter

Ok. So that's my super mega power iptables script I'm
testing for my internet server.

I already put the DHCP rules (my ISP doesn't have a
fixed IP address for the DHCP server. They are always
changing it... don't ask me why) but I didn't test it
yet.

I developed this script using the very good classic
idea: block everything and allow just what I want.

So, this internet server will be a firewall (as soon
as this script works), making NAT (with MASQUERADING).
I also have the SQUID for proxing and caching. 

Some users in my LAN have free pass for everything
while the rest of my users just can connect to the
mail servers (POP and SMTP) and a few users can
connect to ICQ, Messenger, etc (I really don't like
this idea, but I have to do it).

I don't use any authentication method based on user
and password. Instead, I use rules based on the MAC
address for the computers with free pass. (Ok. I know
it isn't a very safe aproach).

So, here goes my script:

INET_IP=`ifconfig eth0 | grep inet | cut -d : -f 2 |
cut -d ' ' -f 2`
INET_IFACE="eth0"

LAN_IP="192.168.0.41"
LAN_IP_RANGE="192.168.0.0/24"
LAN_IFACE="eth1"

LO_IFACE="lo"
LO_IP="127.0.0.1"

Mac1="00:e0:18:3b:af:78"
Mac2="00:50:04:9c:42:23"
Mac3="00:0e:a6:bd:e7:7f"
Mac4="00:c0:df:a5:0c:a5"

IPTABLES="/usr/sbin/iptables"

/sbin/depmod -a
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_state
/sbin/modprobe ipt_REJECT
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp

echo "1" > /proc/sys/net/ipv4/ip_forward

$IPTABLES -F
$IPTABLES -X

$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP

$IPTABLES -N tcp_invalidos

$IPTABLES -A tcp_invalidos -p tcp --tcp-flags SYN,ACK
SYN,ACK \
-m state --state NEW -j REJECT --reject-with tcp-reset
$IPTABLES -A tcp_invalidos -p tcp ! --syn -m state
--state NEW -j LOG \
--log-prefix "Novo nao SYN:"
$IPTABLES -A tcp_invalidos -p tcp ! --syn -m state
--state NEW -j DROP

$IPTABLES -A OUTPUT -p tcp -j tcp_invalidos

$IPTABLES -A OUTPUT -p udp --sport 68 --dport 67 -j
ACCEPT

$IPTABLES -A OUTPUT -p all -m state --state
ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -A OUTPUT -p icmp --icmp-type 8 -j ACCEPT

$IPTABLES -A OUTPUT -p tcp --dport 53 -j ACCEPT
$IPTABLES -A OUTPUT -p udp --dport 53 -j ACCEPT

$IPTABLES -A OUTPUT -p tcp --dport 80 -s $INET_IP -o
$INET_IFACE -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --dport 443 -s $INET_IP -o
$INET_IFACE -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --dport 21 -s $INET_IP -o
$INET_IFACE -j ACCEPT

# ICQ:
$IPTABLES -A OUTPUT -p tcp -d 64.12.163.197 -o
$INET_IFACE -j ACCEPT

$IPTABLES -A INPUT -p tcp -j tcp_invalidos

$IPTABLES -A INPUT -p udp --sport 67 --dport 68 -j
ACCEPT

$IPTABLES -A INPUT -p ALL -m state --state
ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -A INPUT -p tcp --dport 53 -j ACCEPT
$IPTABLES -A INPUT -p udp --dport 53 -j ACCEPT

# SQUID:
$IPTABLES -A INPUT -i $LAN_IFACE -p tcp --dport 80 -j
ACCEPT

$IPTABLES -A FORWARD -p tcp -j tcp_invalidos

$IPTABLES -A FORWARD -m state --state
ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -A FORWARD -m mac --mac-source $Mac1 -j
ACCEPT

$IPTABLES -A FORWARD -m mac --mac-source $Mac2 -j
ACCEPT

$IPTABLES -A FORWARD -m mac --mac-source $Mac3 -j
ACCEPT

$IPTABLES -A FORWARD -m mac --mac-source $Mac4 -j
ACCEPT

$IPTABLES -A FORWARD -p tcp --dport 53 -j ACCEPT
$IPTABLES -A FORWARD -p udp --dport 53 -j ACCEPT

$IPTABLES -A FORWARD -d <my pop server> -p tcp --dport
110 \
-i $LAN_IFACE -j ACCEPT

$IPTABLES -A FORWARD -d <my smtp server> -p tcp
--dport 25 \
-i $LAN_IFACE -j ACCEPT

$IPTABLES -A FORWARD -p tcp --dport 21 -i $LAN_IFACE
-j ACCEPT
$IPTABLES -A FORWARD -p tcp --dport 80 -i $LAN_IFACE
-j ACCEPT
$IPTABLES -A FORWARD -p tcp --dport 443 -i $LAN_IFACE
-j ACCEPT

$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT
--to-source $INET_IP

That's it. Another question: When I configure this
script to run automatically after rebooting the
server, I receive this error message (3 times): "Bad
argument eth0" so the script doesn't work, neither my
Internet access from my LAN and I can't find where is
the error.

However, after rebooting the server and loggin in as
root, I can run the script from command line. It works
and my LAN can access the Internet during that short
time (about 20 minutes. However, I didn't test the
DHCP rules to ckeck if it continues to happen).

Regards
Giancarlo



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <20040909144044.27300.qmail@web50208.mail.yahoo.com>]
* RE: No internet connection
@ 2004-09-09 14:06 Piszcz, Justin Michael
  0 siblings, 0 replies; 14+ messages in thread
From: Piszcz, Justin Michael @ 2004-09-09 14:06 UTC (permalink / raw)
  To: Giancarlo Boaron, netfilter

Perhaps show us the script?

-----Original Message-----
From: netfilter-bounces@lists.netfilter.org
[mailto:netfilter-bounces@lists.netfilter.org] On Behalf Of Giancarlo
Boaron
Sent: Thursday, September 09, 2004 10:05 AM
To: netfilter@lists.netfilter.org
Subject: No internet connection

Hello.
I'm testing a new iptables script on my server box but
after some minuts that this script is running, the
clients in my LAN have no access to Internet.
I'm using SQUID for proxing and caching.

I think I'm not being very restrictive for my IPTABLES
rules because my clients still have Internet access
after about 20 minuts when the script is running.

What can be wrong? Does my kernel have some limit
about connections? Does it hava someting to do with
the CONTRACK?

Regards.
Giancarlo

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



^ permalink raw reply	[flat|nested] 14+ messages in thread
* No internet connection
@ 2004-09-09 14:04 Giancarlo Boaron
  2004-09-09 14:15 ` Jason Opperisano
  0 siblings, 1 reply; 14+ messages in thread
From: Giancarlo Boaron @ 2004-09-09 14:04 UTC (permalink / raw)
  To: netfilter

Hello.
I'm testing a new iptables script on my server box but
after some minuts that this script is running, the
clients in my LAN have no access to Internet.
I'm using SQUID for proxing and caching.

I think I'm not being very restrictive for my IPTABLES
rules because my clients still have Internet access
after about 20 minuts when the script is running.

What can be wrong? Does my kernel have some limit
about connections? Does it hava someting to do with
the CONTRACK?

Regards.
Giancarlo

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-09-10 17:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-10 14:49 No Internet Connection Giancarlo Boaron
2004-09-10 15:33 ` Jason Opperisano
2004-09-10 16:41 ` Aleksandar Milivojevic
2004-09-10 16:56   ` Jason Opperisano
2004-09-10 17:24     ` Aleksandar Milivojevic
2004-09-10 17:28     ` Giancarlo Boaron
     [not found] <20040909144044.27300.qmail@web50208.mail.yahoo.com>
2004-09-09 15:02 ` No internet connection Jason Opperisano
2004-09-09 16:00   ` Nick Drage
2004-09-09 16:25     ` Jason Opperisano
2004-09-09 17:00     ` Aleksandar Milivojevic
  -- strict thread matches above, loose matches on Subject: below --
2004-09-09 14:06 Piszcz, Justin Michael
2004-09-09 14:04 Giancarlo Boaron
2004-09-09 14:15 ` Jason Opperisano
2004-09-09 16:02   ` Nick Drage

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.