LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 08-24-2006, 02:12 PM   #1
sbabcock23
Member
 
Registered: Aug 2006
Location: Mississauga, Ontario, Canada
Distribution: RHEL 5, CentOS 5
Posts: 64

Rep: Reputation: 15
Routing a request to a internal ip address


Hi,

Sorry in advance if this is already posted but I couldn't find anything. Her is what I want to do.
I want to route a request that someone sends a request say 1.1.1.1:2323 and I want it to route to an internal ip address and port for example 192.168.1.100:2324. How can this be done?

Thanks
Steve
 
Old 08-24-2006, 07:25 PM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
iptables -t nat -A PREROUTING -i ethX -p tcp/udp --dport 2323 -j DNAT --to-dest 192.168.1.100:2324
 
Old 08-25-2006, 12:08 AM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
also, just to add to peter_robb's post, don't forget your FORWARD rules, since your FORWARD policy is (hopefully) set to DROP... example:
Code:
iptables -t nat -A PREROUTING -p TCP -i $WAN_IFACE --dport 2323 \
-j DNAT --to-destination 192.168.1.100:2324

iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A FORWARD -p TCP -i $WAN_IFACE -o $LAN_IFACE --dport 2324 \
-d 192.168.1.100 -m state --state NEW -j ACCEPT

iptables -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE
or if you don't wanna do sateful packet filtering:
Code:
iptables -t nat -A PREROUTING -p TCP -i $WAN_IFACE --dport 2323 \
-j DNAT --to-destination 192.168.1.100:2324

iptables -A FORWARD -p TCP -i $LAN_IFACE -o $WAN_IFACE --sport 2324 \
-s 192.168.1.100 -j ACCEPT

iptables -A FORWARD -p TCP -i $WAN_IFACE -o $LAN_IFACE --dport 2324 \
-d 192.168.1.100 -j ACCEPT

iptables -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE
remember to substitute $WAN_IFACE and $LAN_IFACE for your external and internal interface names respectively...

Last edited by win32sux; 08-25-2006 at 12:13 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
Routing on my internal network. Milkman00 Linux - Networking 11 09-02-2005 02:30 PM
Different DocumentRoots depending on external/internal request linorgf Linux - Networking 1 03-14-2005 02:55 PM
Apache: Request exceeded the limit of 10 internal redirects guarriman Linux - General 1 01-26-2005 08:06 AM
RH 9 samsung vm8000 internal modem configuration help request o1hinz Linux - Software 1 10-11-2003 03:21 PM
Internal Routing Saris Linux - Newbie 12 06-24-2003 11:30 PM

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

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