User Agents

Web browsers and everyday web tech, explained

Host Multiple Websites with Different IPs on One VPS

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide shows you how to host several websites, each with its own unique IP address, on a single VPS (Virtual Private Server). This is useful when you need separate IPs for SSL certificates, email reputation, or geo-targeting, without paying for multiple servers. You'll configure your network interfaces, web server, and DNS records to route traffic correctly.

What You'll Need

  • A VPS running Linux (Ubuntu 20.04/22.04 or Debian 11/12) with root or sudo access.
  • Multiple IP addresses assigned to your VPS (check your hosting provider's control panel).
  • Domain names that you control (DNS management access).
  • A web server installed (Apache or Nginx) – we'll cover both.
  • Basic familiarity with the command line and SSH.

Step-by-Step

  1. Verify your IP addresses. Log in via SSH and run ip addr show (or ifconfig). You should see multiple IPs, often on the same interface (e.g., eth0 and eth0:1). Note them down.
  2. Assign additional IPs if not already active. If your provider gave you extra IPs but they aren't showing, you'll need to add them. For Ubuntu/Debian, edit /etc/netplan/01-netcfg.yaml (or your netplan file). Add entries under addresses for each IP. Example:
    network:
      version: 2
      renderer: networkd
      ethernets:
        eth0:
          addresses:
            - 203.0.113.10/24
            - 203.0.113.11/24
    Then run sudo netplan apply.
  3. Set up your web server to listen on specific IPs. For Apache, edit the virtual host configuration (e.g., /etc/apache2/sites-available/example1.conf). Use the <VirtualHost *:80> directive but replace * with the specific IP. For example:
    <VirtualHost 203.0.113.10:80>
        ServerName example1.com
        DocumentRoot /var/www/example1
    </VirtualHost>
    For Nginx, in the server block, use listen 203.0.113.10:80; instead of listen 80;.
  4. Create separate document roots. Make a directory for each site, e.g., /var/www/example1 and /var/www/example2. Add a simple index.html to each to verify later.
  5. Enable the sites. For Apache: sudo a2ensite example1.conf and sudo a2ensite example2.conf, then reload with sudo systemctl reload apache2. For Nginx: create symlinks in /etc/nginx/sites-enabled/ or copy the configs there, then test with sudo nginx -t and reload with sudo systemctl reload nginx.
  6. Configure DNS. In your DNS provider's panel, create A records pointing each domain to its respective IP. For example:
    • example1.com → 203.0.113.10
    • example2.com → 203.0.113.11
    Also add www subdomains if needed.
  7. Test locally. Use curl --resolve example1.com:80:203.0.113.10 http://example1.com to bypass DNS and test the server is responding correctly on that IP.
  8. Wait for DNS propagation. It can take a few minutes to a few hours. Check with dig example1.com or an online DNS checker.

Common Mistakes

  • Forgetting to bind the web server to the specific IP. If you leave *:80 or listen 80, the server will respond on all IPs, which can cause the wrong site to appear.
  • Not updating firewall rules. If you have a firewall (UFW or iptables), ensure it allows traffic on port 80/443 for all the IPs. Some firewalls need explicit rules per IP.
  • Conflicting virtual hosts. If two virtual hosts have the same IP and port, the first one in the config order will be used. Always use distinct IPs or hostnames.
  • Ignoring IPv6. If your VPS has IPv6 addresses, you need to configure them too, or visitors using IPv6 won't reach the correct site.

Tips

  • Use separate virtual hosts for each IP, even if they share the same domain name, to avoid confusion.
  • For SSL, you'll need a certificate for each domain. You can use Let's Encrypt with the webroot or DNS challenge, but ensure the correct IP is used for the challenge.
  • Keep a log of which IP maps to which site – it helps with troubleshooting.
  • If you're using a control panel like Plesk or cPanel, they often have a GUI for assigning IPs to domains – use that instead of manual config.
  • Consider using a reverse proxy if you have many sites – but that would negate the need for multiple IPs.

Troubleshooting

  • Site not loading. Check if the IP is reachable: ping -c 4 203.0.113.11. If not, check your VPS provider's network settings and that the IP is routed to your server.
  • Wrong site shows. This usually means the web server is not binding to the specific IP. Re-check your virtual host configuration and restart the server.
  • DNS not resolving. Verify the A records are correct and that you've waited for propagation. Use dig @8.8.8.8 example.com to query Google's DNS directly.
  • Firewall blocking. Temporarily disable UFW (sudo ufw disable) to test, then re-enable and add the correct rules. Check with sudo ufw status.
  • Port 80 is already in use. Run sudo netstat -tulpn | grep :80 to see which process is using it. If another virtual host is catching all traffic, you may have a default site enabled – disable it.

Frequently Asked Questions

Can I host multiple websites with different IPs on a single VPS without extra cost?

Yes, if your VPS provider gives you multiple IP addresses as part of your plan. Some providers charge extra for additional IPs, so check your plan.

What if my VPS provider only gives me one IP?

You cannot host multiple sites with different IPs unless you purchase additional IPs. However, you can still host multiple sites on one IP using virtual hosts (name-based).

Do I need a separate SSL certificate for each IP?

Yes, each domain needs its own certificate. You can use Let's Encrypt for free, and it's easier now with HTTP-01 challenges, but you must ensure the challenge reaches the correct IP.

Can I use IPv6 addresses instead of IPv4?

Yes, if your provider supports IPv6. You can assign IPv6 addresses to each site, but you'll also need to configure your web server to listen on those addresses.

Will this affect email sending?

It can help with email deliverability if you have a dedicated IP for mail, but that's a separate setup. For web hosting, it doesn't directly affect email unless you also run mail servers.

How do I test if the site is working before DNS propagates?

Use the curl --resolve command as shown in Step 7, or edit your local hosts file to point the domain to the IP temporarily.