Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
hostname based ip routing.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
smileaf
n00b
n00b


Joined: 16 Mar 2005
Posts: 14
Location: USA

PostPosted: Wed Mar 16, 2005 7:14 pm    Post subject: hostname based ip routing. Reply with quote

I was wondering if there is a way to forward ports to differnet Ips based on the hostname from the request.
for example:
hostname1.com:80 -> 192.168.0.1
hostname2.com:80 -> 192.168.0.2
_________________
This has been leafed.
Back to top
View user's profile Send private message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Wed Mar 16, 2005 7:25 pm    Post subject: Reply with quote

Off of the top of my head, I would have to say that you cannot do it with iptables. But somebody will probably tell me that I am wrong.

It looks like you want to setup some virtual web servers. If both ip's are on the same box, then you could just use host headers. If the ip's are on different boxes, then you could use host headers along with apache's proxypass directive, if apache.

http://httpd.apache.org/docs-2.0/mod/mod_proxy.html
Back to top
View user's profile Send private message
smileaf
n00b
n00b


Joined: 16 Mar 2005
Posts: 14
Location: USA

PostPosted: Thu Mar 17, 2005 4:19 am    Post subject: Reply with quote

well what I'd like to setup would not only be for different web servers but also for ssh access directly. so an apache proxy wouldn't exactly be ideal. however this brings in an interesting idea.. what can proxy servers do? :)
_________________
This has been leafed.
Back to top
View user's profile Send private message
Telamon
Tux's lil' helper
Tux's lil' helper


Joined: 29 Dec 2003
Posts: 129

PostPosted: Thu Mar 17, 2005 4:27 am    Post subject: Can't do it for ssh Reply with quote

You can't do it for ssh, or most protocols. The reason it works for web is that it the web browser sends the hostname it's connecting to in it's request to the web server. The web server then parses this "host header" field, and loads the correct page for that hostname.

Most other protocols only receive the IP address in the header, and don't have redirection support in the protocol even if they did know the hostname, so the hostname trick won't work for them. You have to either use a second IP address, or use alternate ports.

So you could bind two IPs to the external interface of your gateway, or use alternate ports, but that's pretty much it. If you are just wanting to use ssh, alternate ports is the way to go. You can put a line in your ~/.ssh/config file to save the alternate portso you don't have to specify it on the command line. Like this:
Code:

Host altone
  Hostname <ip address>
  Port <port>
  HostKeyAlias altone

Host alttwo
  Hostname <ip address>
  Port <alternate port>
  HostKeyAlias alttwo
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum