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 - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-06-2004, 10:11 AM   #1
DarkSun4241
LQ Newbie
 
Registered: May 2004
Posts: 19

Rep: Reputation: 0
newbie question about iptables and samba


Hello


I seem to be have problem understanding iptables in reguards to samba. I finally create a scripts that works, but I not sure why I needed highport connections rules. Is this not what input ESTABLISHED,RELATED rule is for.

Thanks Brian

Below is my firewall script

IPT=/sbin/iptables
IFC=/sbin/ifconfig
MPB=/sbin/modprobe
LSM=/sbin/lsmod
RMM=/sbin/rmmod



IF=eth0
IP=`/sbin/ifconfig $IF | grep inet | cut -d : -f 2 | cut -d \ -f 1`
MASK=`/sbin/ifconfig $IF | grep Mas | cut -d : -f 4`
NET=$IP/$MASK

$IPT -P INPUT DROP
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD DROP
$IPT -F
$IPT -X


for table in filter nat mangle
do
$IPT -t $table -F
$IPT -t $table -X
$IPT -t $table -Z
done


$IPT -N LD 2> /dev/null
$IPT -F LD
$IPT -A LD -j LOG --log-level=info
$IPT -A LD -j DROP

STOP=LD


$IPT -N STATE 2> /dev/null
$IPT -F STATE
$IPT -I STATE -m state --state NEW -i ! lo -j $STOP
$IPT -A STATE -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A STATE -j $STOP

$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#$IPT -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

#SAMBA
$IPT -t filter -A INPUT -p tcp -m state --state NEW -s 0/0 -d 0/0 --dport 137:139 -i $IF -j ACCEPT
$IPT -t filter -A INPUT -p udp -m state --state NEW -s 0/0 -d 0/0 --dport 137:139 -i $IF -j ACCEPT
$IPT -t filter -A INPUT -p tcp -m state --state NEW -s 0/0 -d 0/0 --dport 445 -i $IF -j ACCEPT
$IPT -t filter -A INPUT -p udp -m state --state NEW -s 0/0 -d 0/0 --dport 445 -i $IF -j ACCEPT


# --------( Rules Configuration - Inbound Traffic - Highport Connections )--------

$IPT -A INPUT -p tcp -s 0/0 -d $NET --dport 1024:65535 -j STATE
$IPT -A INPUT -p udp -s 0/0 -d $NET --dport 1023:65535 -j ACCEPT
 
Old 09-10-2004, 09:44 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Code:
#!/bin/sh

IPT="/sbin/iptables"
IF="eth0"
LO="lo"
LO_IP="127.0.0.1"

/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack

echo "1" > /proc/sys/net/ipv4/tcp_syncookies
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo "1" > /proc/sys/net/ipv4/conf/all/log_martians

$IPT -F
$IPT -F -t nat
$IPT -F -t mangle
$IPT -X
$IPT -X -t nat
$IPT -X -t mangle
$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP
$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT

$IPT -A INPUT -p ALL -m state --state INVALID -j DROP
$IPT -A INPUT -p ALL -i $LO -s $LO_IP -j ACCEPT
$IPT -A INPUT -p TCP ! --syn -m state --state NEW -j DROP
$IPT -A INPUT -p TCP -i $IF --dport 137:139 -j ACCEPT
$IPT -A INPUT -p UDP -i $IF --dport 137:139 -j ACCEPT
$IPT -A INPUT -p TCP -i $IF --dport 445 -j ACCEPT
$IPT -A INPUT -p UDP -i $IF --dport 445 -j ACCEPT
$IPT -A INPUT -p ALL -j LOG --log-prefix "INPUT DROP: "

$IPT -A OUTPUT -p ALL -m state --state INVALID -j DROP
$IPT -A OUTPUT -p ALL -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p ALL -o $LO -s $LO_IP -j ACCEPT
$IPT -A OUTPUT -p ALL --log-prefix "OUTPUT DROP: "

echo "So let it be written, so let it be done..."
no more high port BS... just my two cents...

=)


Last edited by win32sux; 09-10-2004 at 09:47 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
Newbie question about iptables/shorewall syeronne Linux - Security 4 12-05-2005 04:18 PM
iptables newbie question Beauford-2 Linux - Security 4 09-26-2004 04:41 AM
iptables newbie question TurtleBay Linux - Newbie 10 10-09-2003 02:37 PM
Newbie Question - IPTables cyberperson Linux - Networking 1 03-14-2003 10:22 PM
Iptables newbie / simple question wr3ck3d Linux - Networking 2 03-06-2003 08:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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