LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   iptables (http://www.linuxquestions.org/questions/linux-networking-3/iptables-492129/)

p-uk 10-13-2006 11:31 AM

iptables
 
Hey

So, I had to rebuild my RH9 machine after a hardware fault and chose CentOS 4.4. All was looking good and then I realised I didn't have a backup of my firewall script. No big deal, I used a pretty standard one but the customised NAT/MASQ was not backed up anywhere.

So I have put some NAT/MASQ commands in but I cannot resolve an issue for traffic on one port I am configuring. Although I have put the recommended lines into the script, I can still see packets being dropped in my /var/log/messages file.

Here's the scoop...

pre-amble:

Code:

ExtIF is eth1 on my gateway, IP xxx.xxx.xxx.xxx
IntIF is eth0 on my gateway, IP 192.168.1.1
IP of my local machine is 192.18.1.19
NAT of 192.168.1.19 to external machines on port 1412

lines in my firewall script for NAT:

Code:

$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT

$IPTABLES -A FORWARD -j drop-and-log-it

$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j SNAT --to $EXTIP

$IPTABLES -t nat -A PREROUTING -i $EXTIF -p tcp -d $EXTIP --dport 1412 -j DNAT --to 192.168.1.19:1412
$IPTABLES -t nat -A PREROUTING -i $EXTIF -p udp -d $EXTIP --dport 1412 -j DNAT --to 192.168.1.19:1412

It would appear that my IP is being forwarded out but traffic returning is being dropped (entries in /var/log/messages):

Code:

Oct 13 17:00:00 host kernel: IN=eth1 OUT=eth0 SRC=999.999.999.999 DST=192.168.1.19 LEN=48 TOS=0x00 PREC=0x00 TTL=115 ID=34746 DF PROTO=TCP SPT=2900 DPT=1412 WINDOW=64240 RES=0x00 SYN URGP=0
(actual external IP replaced with 999.999.999.999)

I am unsure whether I need to add other rules regarding established packets etc. but if anyone can enlighten me to my error/omission, I would be grateful.

Thanks

P

peter_robb 10-13-2006 11:44 AM

The packet example you showed in your log example is a SYN packet which is the first packet of a NEW connection, and you don't have a rule to ACCEPT NEW packets..

The NEW rule needs to be just for that port. Otherwise everything gets in..

A better listing comes from iptables-save.
This shows what is active and in actual sequence..

p-uk 10-22-2006 04:46 AM

Thanks Peter


All times are GMT -5. The time now is 11:52 AM.