Enable Internet on server with only Private IP


We have two servers one server named webserver that have both Public and Private IP we up another server named dbserver that have only private IP.

While accessing internet on dbserver we are not getting so please how we can able enable internet on dbserver with NAT.

Can anyone please help us with iptables rules for enabling NAT.



What are you trying to accomplish? Access to your database server from the “outside”?


I read that @pcgeopc has no connection to the internet on his dbserver. He assumes that the lack of a »public IP« is the cause and suggests deploying NAT, at least for that case.

In the third paragraph he asks for the commands for IP masquerading using iptables.


Yes @marc that’s my need. Can you please update us the steps.


@mark Thank you - well, I read that too :wink:
The question is, why are you assuming that you don’t have an internet connection on your private server?
The public server is basically nothing else than a private server. The public IP adressed is assigned to the router which routes the traffic to the desired server.


Well, “private server” comes across as “server that cannot be accessed from outside”. But without a public IP assigned, I kind of expected there would indeed be no way out from the server directly… at least without going through the other server that does have its public IP address.


Good point @felix. So - assuming the private server does really not have internet access because of the lacking public IP, I think @pcgeopc just have to activate ip forwarding at the public server and configure it as gateway on the private server.


Here is a similar question and good answer:

1 Like

Thanks to all for the update. Will check squid implementation and let you know…


refer to this URL (https://unix.stackexchange.com/questions/116191/give-server-access-to-internet-via-client-connecting-by-ssh) too, it shows you how to setup a computer A (with Internet connection) for another computer B (without internet connection) as a proxy (using squid install on A).
It works for me. (save you 1EUR for each scaleway instance without need a Public IP, but you still an use command such as “apt update”.