LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-05-2013, 01:08 PM   #1
wastingtime
Member
 
Registered: Sep 2004
Posts: 86

Rep: Reputation: 17
iptables: how to forward locally accessed port to a remote machine


My goal is to forward the local port 8088 on one machine to a remote machine.

The local machine has an eth0 interface (10.0.0.10) and lo (127.0.0.1).

On 10.0.0.10 the rules
Quote:
iptables -t nat -A PREROUTING -p tcp --dport 8088 -j DNAT --to-destination 10.0.0.20:8088
iptables -t nat -A POSTROUTING -p tcp -d 10.0.0.20 -j MASQUERADE
Allows me to connect from a third machine (10.0.0.30) to 10.0.0.10 and that connection is forwarded to 10.0.0.20.

This works and connects to 10.0.0.20
Quote:
[10.0.0.30~] telnet 10.0.0.10 8088
However, from 10.0.0.10 itself the connection fails. This does not work
Quote:
[10.0.0.10~] telnet 10.0.0.10 8088
Adding this rule allows me to connect to the eth0's address from the local machine
Quote:
iptables -t nat -A OUTPUT -p tcp --dport 8088 -j DNAT --to-destination 10.0.0.20:8088
Now this does work
Quote:
[10.0.0.10~] telnet 10.0.0.10 8088
However, connecting to the lo interface still does not work
Quote:
[10.0.0.10~] telnet 127.0.0.1 8088

I'm looking for a rule on 10.0.0.10 that will forward the connection to 127.0.0.1 port 8088 to 10.0.0.20 port 8088

I googled this problem to no end and found suggestions that either do not work, or are syntactically wrong

Please only reply with a rule that is known to work.

Thanks.
 
Old 04-06-2013, 06:06 AM   #2
gangadhar402
Member
 
Registered: Mar 2013
Location: the India
Distribution: Ubuntu,Debian and CentOS
Posts: 35

Rep: Reputation: 2
Hi,



http://www.cyberciti.biz/tips/linux-...-examples.html


this may helpful ....
 
  


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
[SOLVED] Iptables: how to redirect locally-generated packets to a remote server? briwood Linux - Networking 28 02-16-2016 10:35 PM
Iptables can't port forward (PAT Port address translation) sfrederiksen Linux - Networking 7 12-20-2011 11:47 AM
how to port forward AND process locally as well? lynz Linux - Networking 2 09-28-2006 12:37 AM
How to mount remote server locally to a machine? ammar Linux - Networking 1 08-18-2006 02:02 AM
built kernel locally...need to install to a remote machine. how? ARCHIGAMER Linux - General 1 04-10-2005 03:52 PM

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

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