LinuxQuestions.org
Help answer threads with 0 replies.
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 06-14-2008, 01:59 PM   #1
garnser
Member
 
Registered: Aug 2004
Location: Sweden
Distribution: Fedora Core, OpenBSD and FreeBSD
Posts: 37

Rep: Reputation: 15
Question Repoint traffic to "black ip" based on DNS name


Hi everyone.

I currently have a couple of servers at home sitting on a consumer type DSL with 1 static IP which terminates to a Linux gateway.

To this I've a domain which points to my gateway.
Example: example.com points at 123.123.123.123

What I'm trying to achieve is the following:
Example: host1.example.com points at 123.123.123.123

If host-request is host1.example.com, forward traffic to 192.168.1.4

I've tried to do this using:
iptables -t nat -A PREROUTING -d host1.example.com -j DNAT --to-destination 192.168.1.4

but it wont do the trick.

Please advice.
 
Old 06-14-2008, 02:28 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If your home static IP is 123.123.123.123, then all unicast traffic that gets to that gateway will have that same destination IP. The only way to distinguish between the hosts to which specific packets should be redirected would be by port number. Even though you may have multiple DNS records 'pointing' to the same IP, any reference to those IP names is lost once the packet has been sent. There is no name content in the packet in transit, only the actual numeric address.
With respect to your iptables rules, you would need to add a rule that actually does the forwarding of the packet. Your rule should be good for translating the packet into one that would find its way to the intended host, but you need a FORWARD rule to actually get it sent. Something like:
Code:
iptables -A FORWARD -d 192.168.1.4 --dport 80 -j ACCEPT
This example uses port 80, assuming your server is an HTTP server. You might need to add a parameter about what interface the original packet came from.
--- rod
 
Old 06-14-2008, 02:31 PM   #3
garnser
Member
 
Registered: Aug 2004
Location: Sweden
Distribution: Fedora Core, OpenBSD and FreeBSD
Posts: 37

Original Poster
Rep: Reputation: 15
Are you sure that the "IP name" is lost. If you're using virtual hosts with apache it's able to distinguish the names properly, is it that iptables is unable to do this?
 
Old 06-15-2008, 12:14 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Okay, we're both right. After a short experiment with wireshark, I see that at the pure TCP level, where iptables does its work, there is no name information in the packet. For an HTTP request packet, there is a header in the data frame of the packet which identifies the host by name, called the "Host:" header. That would be what allows a web server to host multiple virtual servers. I always wondered about that.
--- rod.
 
Old 06-15-2008, 01:36 AM   #5
garnser
Member
 
Registered: Aug 2004
Location: Sweden
Distribution: Fedora Core, OpenBSD and FreeBSD
Posts: 37

Original Poster
Rep: Reputation: 15
So final verdict is that I'm SOL for this solution, guess I'll have to go with SSH tunneling instead.

Thanks
 
  


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
Fedora 8 - Black screen after boot - "Loading" cursor displaying :( rmwebs Linux - Desktop 3 04-03-2008 09:35 AM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
nvidia 7174 widescreen laptop 2.6.x xorg = "black screen" khermans Linux - Hardware 4 04-10-2005 08:28 AM
RH9 installation seemed ok, but bootup stops on a fat black "x" & won't respond. bikethief Red Hat 2 02-01-2004 08:18 AM
Inst mandrake, screen black after"if u can read this press OK" ReallyStupidGuy Linux - Newbie 2 12-04-2002 03:44 PM

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

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