How to set up a website on NAT VPS?

NAT VPS is cheap for it has no dedicated IPV4 address. After you order a NAT VPS, you will receive an email which includes the configuration information about your server. The most important information is the internal IPV4 address, the external IPV4 address, and some IPV6 addresses. Note that the internal IPV4 address is not necessarily the private(or reserved) address, i.e., an ip whin the block –, –, –, but you cannot access your VPS externally using this internal ip address. Using the ifconfig command on your VPS, you will find the internal IP address is assigned to an network interface. You will also find the ipv6 addresses assigned to the network interfaces of your VPS. But you won’t find the external ipv4 address in the email. The external ipv4 address belongs to a router separated from your VPS, which acts as a NAT device. The NAT device forwards the ip packets from outside to inside,and vice versa. In other words, you can access the router using the external ipv4 address with a specified port number. Suppose you are given the internal ip address, the external ip address, then typically,  your vps will also be assigned the range of ports 2000-2020. You can communicate with the external ipv4 address/port When the daemon(proxy) running on the router receives the packets coming through port between 2000 and 2020, it will forward them to your VPS inside the private network with the port number unchanged(with one exception that 2000 will be changed to 22, which is used to communicate with sshd listening on port 22 on your VPS).

Knowing the basics of NAT VPS, we can start to set up our website on the NAT VPS now. The whole process is most similar to that on an ordinary VPS(i.e., a VPS with a dedicated IPV4 address). You can refer to this tutorial  for the detailed steps and instructions to setup a website on CentOS with Apache. The only difference is to change the listening port from 80 to some port that is assigned to your VPS(i.e., a port between 2000 and 2020). Specifically, if you select 2012 as the port Apache listens on, you should change “Listen 80″ to “Listen 2012″, change “NameVirtualHost *:80″ to “NameVirtualHost *:2012″ and change “<VirtualHost *:80>” to “<VirtualHost *:2012>”. And don’t forget to add an A record pointing to the external ipV4 address( the name server of your domain. The inconvenient thing here is that you have to visit your website by appending the port to the domain name,like If you just want to test the apache server and do not want a domain name for your website, you don’t need to add the virtual host to the httpd.conf. Just type and you can see your website. You can refer to this guide  if you do not know where to put your website files.

Wait a minute, we have a real ipv6 address that has not been used yet. We can use this ipv6 address to setup a normal website that can be visited by its domain name solely(i.e., The method is very straightforward, just add an AAAA record pointing to this ipv6 address on the name server of your domain name and keep the listening port (80) in the  apache configurtation file untouched.   The problem is that most people on the internet would  never see your website because they are on ipv4 network which cannot interconnect with ipv6 network easily. Although there are many ways to access IPV6 websites from IPV4 network such as using a tunnel or proxy, the most simple way seems to use the IPV4/IPV6 gateway service provided by, it seems has a cache mechanism, and you cannot see the updated version of your website timely).

Posted in tips of hosting