logo
. . .

A Step-by-Step Guide: Adding Additional IP Addresses in Ubuntu for Hosting Multiple Websites

Step 1: Accessing Your Ubuntu 20.04 Server
Begin by logging into your Ubuntu 20.04 server using SSH. Once connected, you’ll have access to the command line interface, where you’ll perform all the necessary configurations
ssh your_username@your_server_ip

Step 2: Check Current Network Configuration
Before adding additional IP addresses, it’s essential to know your server’s current network configuration. Use the following command to display network information:
#ip addr show
This will list your current network interfaces and their assigned IP addresses.

Step 3: Configure Additional IP Addresses
To add an additional IP address, you need to modify the netplan configuration files. Open the appropriate file in a text editor, such as nano or vim:

#sudo nano /etc/netplan/00-installer-config.yaml
Add the following lines under the network section, ensuring proper indentation:

yaml
Copy code
network:
version: 2
ethernets:
ensXX:
addresses:
– your_additional_ip/24
Replace ensXX with your actual network interface name and your_additional_ip with the IP address you want to add.

Save the file and apply the changes:
#sudo netplan apply

Step 4: Verify the New IP Address
Confirm that the additional IP address has been successfully added by running:
#ip addr show
You should now see the newly added IP address listed under your network interface.

Step 5: Configure Web Server for the New IP
Adjust your web server configuration to recognize the new IP address. This process varies depending on your web server of choice (e.g., Apache or Nginx). Update the server block or virtual host configuration with the new IP address.

Step 6: Test Your Configuration
Restart your web server to apply the changes and ensure that your websites are accessible via the newly added IP address. Test by accessing your websites in a web browser using both the old and new IP addresses.

Conclusion:
By following these steps, you’ve successfully added an additional IP address to your Ubuntu 20.04 server, paving the way for hosting multiple websites with enhanced security and resource management