LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 04-23-2013, 09:49 AM   #1
pasin
LQ Newbie
 
Registered: May 2012
Posts: 4

Rep: Reputation: Disabled
access private ip from public ip


Hello everybody!
Hoping I am in the right part of the forum,
I need to know how can I practically create this scenario.
I have a server with a private ip which can be accessed from outside through a public ip.
But I need to also access another server(private ip) through the public ip that I have from the first server.
So for exampe
I have server1 with prc ip 192.168.1.x that can be accessed from outside through and public ip(x.x.x.x)
I also have another server 192.168.1.y. I need to access this server through for example x.x.x.x/sth to point to the second server.
 
Old 04-23-2013, 11:45 AM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,582

Rep: Reputation: 480Reputation: 480Reputation: 480Reputation: 480Reputation: 480
you would set it up the same way you setup the first server. NAT is your friend.

you just can not have the same port forwarded to multiple private IPs.
 
Old 04-23-2013, 12:26 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
First, explain the nature of the public/private server. Is it running a modern-ish version of Linux? It does have two network interfaces?

In general terms, the public/private server will need to become a router, and it will need to port-forward a public IP port to the private LAN IP/port. This will involve the use of netfilter rules, which you configure from userspace using the iptables utility. Generally, the ruleset is crafted as a shell script that you run to establish or alter the behavior of the router. Without having a fairly sound understanding of such rules, your easiest and best approach would be to use a canned package that provides a way to add this. I use and like HomeLanSecurity; there are others which also support the topology I assume your are using now.

--- rod.
 
Old 04-24-2013, 01:56 AM   #4
eklavya
Member
 
Registered: Mar 2013
Posts: 590

Rep: Reputation: 131Reputation: 131
In your router setting, you have defined your server's LAN's IP as static IP (public IP).
Suppose your server's LAN IP is 192.168.1.9 and your static IP (public IP) is 109.89.85.3.
You have defined it in your router setup that this LAN IP should be accessible as public IP.

Now you want to do that different system of same LAN should act as a server. There are two ways.
1) Change the defined LAN IP for public IP in router setup and set the LAN IP of your new system there.
2) Change the LAN IP of your current server and give this IP to your new system.so the system will become server.
 
Old 04-24-2013, 02:07 AM   #5
pasin
LQ Newbie
 
Registered: May 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
What I am trying to do in more simple words is:
I have 2 servers, each one containing a web site, but I have only one public ip.
The first prv ip is associated with the public ip, but how can I acceess also the other private ip using the same public ip?
I have installed Centos 5.5
 
Old 04-24-2013, 03:23 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6
Posts: 1,602

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
Install Squid on the box with the public facing IP and then use squid as a "reverse proxy" There's quite a few threads on here about it, just search for squid reverse proxy I've never done it, just seen similar questions asked on here.
 
Old 04-24-2013, 05:59 AM   #7
eklavya
Member
 
Registered: Mar 2013
Posts: 590

Rep: Reputation: 131Reputation: 131
You can access only one server at a time with public IP.
You will have to change the private IP of server which one you want to make active.
 
Old 04-24-2013, 06:22 AM   #8
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6
Posts: 1,602

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
Quote:
Originally Posted by eklavya View Post
You can access only one server at a time with public IP.
Not exactly correct:

1) A slight expansion on my previous post:
http://wiki.squid-cache.org/SquidFaq/ReverseProxy
"The Squid redirector can make one accelerator act as a single front-end for multiple servers. If you need to move parts of your filesystem from one server to another, or if separately administered HTTP servers should logically appear under a single URL hierarchy, the accelerator makes the right thing happen."
2) Using different ports (now quite what the OP had in mind, but easily do-able with most good routers).
Just random thinking as I've never tried it but could have a global redirect on the server listening on port 80 to redirect all requests to the folder /blah to http://w.x.y.z:81/blah
3) "Appliances"
We use several of these and use a single public IP to access 3 web servers.
 
Old 04-24-2013, 12:06 PM   #9
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by pasin View Post
What I am trying to do in more simple words is:
We don't need things to be simplified; we need more details.
I've already asked for those details. Without knowing what you already have, no one can produce a relevant answer.
If your 'server' is a Linux host with two ethernet interfaces, then a solution should be quite simple. We need you to describe the network topology, and the nature of all of the hosts involved, especially the OS and any network related hardware.

--- rod.
 
Old 04-24-2013, 11:25 PM   #10
spartha
LQ Newbie
 
Registered: Mar 2013
Posts: 5

Rep: Reputation: Disabled
I did this

Quote:
Originally Posted by pasin View Post
What I am trying to do in more simple words is:
I have 2 servers, each one containing a web site, but I have only one public ip.
The first prv ip is associated with the public ip, but how can I acceess also the other private ip using the same public ip?
I have installed Centos 5.5
Well, first can you access your second server from your first? If no, get the reachability between these two.

We are going to make Serv1 as a router/firewal and webserver.

Are you using urls to access both the websites or ip/port? if using urls -
- use your dns to map the 2 urls to two different ports for the public ip. (x.x.x.x: port1 for serv1 and x.x.x.x: port2 for serv2 where x.x.x.x is your public ip)
- Now enable ip forwarding on serv 1 (http://www.ducea.com/2006/08/01/how-...ding-in-linux/)
- use ip tables to perform NAT and map x.x.x.x: port1 to serv1:80 and x.x.x.x: port2 to serv:80 (http://www.howtoforge.com/nat_iptables)

let me know if you have specific questions in doing this.

- Partha
 
  


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
VPN over Public interface then access to Private Network stuartornum Linux - Networking 3 10-20-2011 03:09 AM
public and private network here2serve Linux - Distributions 7 12-03-2006 01:34 AM
Public Access of Internet using Private IP manas484 Linux - Security 1 01-17-2006 06:09 AM
public vs private ip emailssent Linux - Networking 2 09-28-2004 03:11 AM
Linking Public IP to a Private IP Saints Linux - Networking 0 05-04-2004 05:33 AM


All times are GMT -5. The time now is 01:53 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration