LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
 
LinkBack Search this Thread
Old 10-16-2006, 03:07 AM   #1
crowhurst01
LQ Newbie
 
Registered: Oct 2006
Posts: 6

Rep: Reputation: 0
iptables nat port forwarding rule set


I have been trying to do a port forward, but I am new to iptables.

I have two ethernet ports: eth0 WAN, and eth1 LAN

I want anything which hits eth0 dport 2222 to be forwarded out eth1 to 192.168.1.5:8000

Do I need to do a FORWARD, PREROUTE and POSTROUTE rule? Or can I just do a PREROUTE

I tried this with no luck:

sudo iptables -A FORWARD -i eth0 -p tcp --dport 2222 -j ACCEPT
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2222 -j DNAT --to-destination 192.168.1.5:8000


Do I need the:
sudo iptables -A FORWARD -i eth0 -p tcp --dport 2222 -j ACCEPT
or will PREROUTE work without it?

Do I need to FORWARD if I already have a routing table set up?
 
Old 10-16-2006, 05:11 AM   #2
JiYu
LQ Newbie
 
Registered: Sep 2006
Location: Germany
Distribution: FreeBSD
Posts: 29

Rep: Reputation: 15
for an example:

Code:
PORT=443
DMZ_IP=192.168.99.99
DMZ_IF=eth2

/sbin/iptables -A PREROUTING -t nat -p tcp --dport $PORT -i ppp0 -j DNAT --to $DMZ_IP:$PORT
/sbin/iptables -A FORWARD -p tcp -d $DMZ_IP --dport $PORT -i ppp0 -o $DMZ_IF -j ACCEPT
/sbin/iptables -A FORWARD -p tcp -s $DMZ_IP --sport $PORT -i $DMZ_IF -o ppp0 -j ACCEPT
 
  


Reply

Tags
forwarding, iptables, nat


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 08:35 PM
Problem with port forwarding (NAT) on FC 5 heberrdacruz Linux - Networking 49 08-20-2006 01:32 AM
iptables port 80 rule Q doronunu Linux - Security 3 06-04-2006 07:55 PM
NAT and Port Forwarding aq_mishu Linux - Networking 2 09-16-2005 08:58 AM
iptables + NAT + Port forwarding problem SirGertrude Linux - Networking 9 05-14-2004 05:02 AM


All times are GMT -5. The time now is 02:45 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
Open Source Consulting | Domain Registration