LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 02-10-2002, 07:57 PM   #1
jamesws
LQ Newbie
 
Registered: Feb 2002
Posts: 3

Rep: Reputation: 0
Angry iptables and port forwarding


I'm in need of help.

I have a firewall setup.
The internal lan can access the web.

I tried to setup Portfordwarding to an internal web server on port 80 ip 192.168.254.15.

here is the script I'm using.
I replaced my EXTIP with X

#!/bin/sh

PATH=/sbin:$PATH; export PATH

iptables -F
iptables -F -t nat
iptables -X

EXTIP=XXX.XXX.XXX.XXX
EXTNET=eth1
INTNET=eth0


iptables -t nat -A PREROUTING -p tcp --destination 440 -j ACCEPT

iptables -t nat -A PREROUTING -p TCP -i eth1 -d 204.$EXTIP --dport 80 -j DNAT --to 192.168.254.15:80

iptables -N firewall
iptables -A firewall -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A firewall -m state --state NEW -i ! $IFINET -j ACCEPT
iptables -A firewall -s 127.0.0.1 -d 127.0.0.1 -i lo -j ACCEPT
iptables -A firewall -s 127.0.0.1 -d 192.168.254.0/24 -i lo -j ACCEPT
iptables -A firewall -d 127.0.0.1 -s 192.168.254.0/24 -i lo -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -p tcp -i eth1 -j ACCEPT

iptables -A INPUT -j firewall
iptables -A FORWARD -j firewall

iptables -A INPUT -j DROP

iptables -t nat -A POSTROUTING -o $EXTNET -j SNAT --to $EXTIP

iptables -A FORWARD -p TCP -i eth1 -o eth0 -d 192.168.254.15 --dport 80 -j ACCEPT

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

Last edited by jamesws; 02-11-2002 at 02:11 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 port forwarding geoff3425 Slackware 13 12-20-2011 11:50 AM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 08:35 PM
IPTables port forwarding.. NeoTech Linux - Networking 2 01-03-2005 12:27 PM
port forwarding with iptables David_99 Linux - Security 5 12-09-2003 09:37 PM
IPTABLES port forwarding sal_paradise42 Linux - Networking 5 10-25-2003 05:11 PM


All times are GMT -5. The time now is 10:35 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration