LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 05-25-2009, 02:00 AM   #1
JohnRock
Member
 
Registered: May 2009
Posts: 36

Rep: Reputation: 15
Best way to hide my database from the internet ...Nat?


I am looking for advice on a what I am sure is a very basic procedure but I have never had to set this up before and am not sure where to start.

I am running 2 CentOS5.3 boxes.
I have one webserver connected to the internet and behind a firewall. I would like to set up the 2nd server (database) behind the webserver and completely inaccessible from the internet. Ideally so it can only be accessed by first ssh'ing onto the webserver and then ssh'ing from there onto the database. The webserver connecting locally to database.

From what I have seen it looks like I need to set this up using NAT but I have never done this and do not know what is involved.

Can someone point me in the right direction and optimally outline the steps I need to take to hook this up? Do I need to worry about any specific hardware configuration as well?

Thanks in advance!
 
Old 05-25-2009, 06:47 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
I would need to know how these machines are connected between them, and to the internet.

There's no straight way that anyone (sort of hacking your router or web server) will be able to access your db server unless it's connected straight to the internet, or your router is doing some kind of routing to connect whatever port you are using on the db box to the external world.

I think you are using a topology that's similar to this one:

Code:
db server  \
            switch/hub --- router --- internet
web server /
Or maybe the router is *also* the web server?

In any case, NAT is used to translate IP's between the "real world" and your private network, thus, allowing for example many machines that are behind a router to access the internet with the same IP (this of your router). I don't see how that relates to your problem, so, either NAT isn't what you are looking for or I have misunderstood something.

As long as your machines are not routed to the external world they should be invisible from the world outside.

Last edited by i92guboj; 05-25-2009 at 06:48 AM.
 
Old 05-25-2009, 06:51 AM   #3
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
I'd suggest putting a router between your computers and the internet. As long as it supports port forwarding (and most do), you can forward any needed ports to the web server and the database server would be inaccessible (well, mostly).

Quote:
The webserver connecting locally to database.
As long as your webserver connects to the database, it is theoretically accessible from the internet if your webserver were to be cracked. You still need proper security on the database server.
Quote:
Ideally so it can only be accessed by first ssh'ing onto the webserver and then ssh'ing from there onto the database.
I'm not sure this adds a lot in terms of security. SSH (when configured properly) is a pretty tough nut to crack and allowing direct SSH access to the database server isn't much of a risk. To be honest, I think the most direct threat to your database server would be from exploits on the webserver.
 
Old 05-25-2009, 03:06 PM   #4
JohnRock
Member
 
Registered: May 2009
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Hangdog42 View Post
I'd suggest putting a router between your computers and the internet...
Thanks for your input. Yes, my current configuration is quite simple and there is no router involved. My datacenter tech had suggested that to achieve my simple goal (of having the database unaccessible directly) I set up a NAT IP for it on the webserver.

Not having experience with this, I am not sure if that suggestion is a good one or even possible, but I suspect he may have been suggesting that as a way of me avoiding additional charges for him setting up a router and a LAN on my two servers? Does that make any sense?

Is it possible to make such a configuration using a NAT IP without using a router?
 
Old 05-25-2009, 03:59 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
We still don't know how your machines are connected, so I am not sure of what he mean. But I can't imagine why NAT would help at all.

It's usually quite the oposite, as I said on my other post, NAT can be used to connect a machine that's behind a router to the internet, which is exactly the opposite of what you intend to do. If you want the web server to access a machine that's on your internal network you don't need to do anything special, and that machine will not be visible from the outside.

Try to describe how is your net, how are both machines connected. I assume that only the web server is connected to the internet, if not, let us know about that as well.
 
Old 05-26-2009, 06:51 AM   #6
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Not having experience with this, I am not sure if that suggestion is a good one or even possible
What your datacenter tech seems to be suggesting is to turn your webserver into a router of sorts. Network traffic has to be able to move between the two machines, so you need some sort of networking capability on your webserver.

Quote:
but I suspect he may have been suggesting that as a way of me avoiding additional charges for him setting up a router and a LAN on my two servers?
A decent stand-alone router would set you back about US $100, which isn't trivial, but may be money well spent. As far a setting up the LAN, if you can plug network cables in, you can set up the LAN yourself. Most modern routers are VERY easy to self-administer.

An i92guboh is absolutely right, if we can get a better idea of what your network currently looks like, we can give better advice.
 
Old 05-27-2009, 04:56 PM   #7
JohnRock
Member
 
Registered: May 2009
Posts: 36

Original Poster
Rep: Reputation: 15
Thanks for all your help. It seems that there was in fact some misunderstanding from my datacenter tech and his initial advice was erroneous..which is what confused me. There was indeed no need for dealing at all with NAT. I had him install a second NIC in each server and assigned a private ip to each card. Now my webserver connects on the local ip to the db and I completely disabled the public ip on the db so it is pretty well hidden behind the webserver.

This should do the trick. Thanks

John
 
Old 05-27-2009, 05:14 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
That was my impression, it was some misunderstanding. Glad that you figured it out and found an adequate setup
 
  


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
NAT - 2 internet connections bzzz Linux - Networking 4 12-14-2007 04:22 PM
Hide Internal IP Adresss From Internet flankovich Linux - Newbie 5 08-22-2006 06:46 PM
nat for internet connection alaios Linux - Networking 2 07-17-2005 02:21 PM
who are supposed to NAT in an Internet? cranium2004 Linux - Networking 1 05-13-2005 06:19 AM
Internet Connection - NAT sabaum Linux - Networking 2 02-21-2005 06:00 PM

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

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