LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-08-2010, 03:56 PM   #1
genmaicha
Member
 
Registered: Apr 2009
Posts: 38

Rep: Reputation: 15
port forwarding to arbitrary address?


Is it possible to forward a connection to a port to a completely unrelated external address? For example, I want to redirect ssh traffic to a.b.c.d to w.x.y.z. If w.x.y.z were an internal address and the machine was the router, this would just be plain old NAT port forwarding. But what if w.x.y.z is not an internal address?

The reason I want to do this is I want to reassign a domain name example.com from ip address A to B, while allowing users to still ssh into A by using the example.com domain name. Is this unreasonable?*

(I am guessing it is unreasonable, since the A wouldn't have it's gateway set to B, as is the case if A were in B's NAT'd internal network.)

Smarter ideas highly welcomed.
 
Old 02-08-2010, 04:42 PM   #2
genmaicha
Member
 
Registered: Apr 2009
Posts: 38

Original Poster
Rep: Reputation: 15
wait... I can do this with netcat/socat, can't I?
 
Old 02-08-2010, 05:02 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
If you are using IPTables it is quite simple. Just set up a rule which DNATs port 22 to A and port 80 to B. AFAIK it doesn't matter that the IP address is external. The output mangling is the last chain, so if you redirect to an outside address the traffic is NATted (Masqueraded) just like any internal traffic going to the outside.

jlinkels
 
  


Reply



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
Port/Address forwarding with iptables with one network interface. Nextrastus Linux - Networking 5 09-18-2013 09:55 AM
Shorewall: port forwarding problem, port is closed even after forwarding Synt4x_3rr0r Linux - Networking 2 12-13-2009 04:36 PM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Port Forwarding per IP Address Linux and Win2k3 carl.waldbieser Linux - Networking 1 01-05-2006 05:47 PM
how to set a static ip address or do port forwarding? cd1680 Linux - Networking 13 03-27-2005 06:58 PM

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

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