This guide explains how to add multiple IP addresses to your server's network interface. This is useful for hosting multiple websites with dedicated IPs, managing different services, or implementing specific network configurations.
- Introduction
- Beyond your primary IP address, you might need additional IP addresses for various purposes:
- Hosting multiple SSL certificates on separate IPs (though SNI often makes this less necessary now).
- Assigning a dedicated IP to a specific service or customer.
- Isolating traffic for different applications.
- The common method is IP Aliasing, where multiple IP addresses are assigned to a single physical network interface.
- Beyond your primary IP address, you might need additional IP addresses for various purposes:
- Linux Servers (CentOS, Ubuntu, Debian)
- Method 1: Temporary IP Alias (Lost on reboot)
- Quickly add an IP for testing. Replace ens18 with your interface name.sudo ip addr add 192.168.1.11/24 dev ens18
For IPv6:
sudo ip addr add 2001:db8::11/64 dev ens18
- Verify immediately: ip a
- Method 2: Persistent Configuration (Recommended)
- Ubuntu/Debian (using Netplan):
- Edit your Netplan YAML file (e.g., /etc/netplan/01-netcfg.yaml).
- Add the new IP address(es) to the addresses list for your interface.network:version: 2renderer: networkdethernets:ens18:dhcp4: noaddresses:- 192.168.1.10/24 # Your primary IP- 192.168.1.11/24 # Your new additional IP- 192.168.1.12/24 # Another new IP (optional)routes:- to: defaultvia: 192.168.1.1nameservers:addresses: [8.8.8.8, 8.8.4.4]
If adding IPv6:
dhcp6: no
addresses:
- "2001:db8::10/64"
- "2001:db8::11/64"
- Apply the changes:sudo netplan apply
- Verify: ip a
- CentOS/RHEL 7/8 (using NetworkManager & ifcfg files):
- You can often add multiple IPs directly within the primary ifcfg-your_interface_name file.
- Edit /etc/sysconfig/network-scripts/ifcfg-ens18 (replace ens18).
- Add additional IPADDR and PREFIX lines with a numerical suffix:TYPE=EthernetBOOTPROTO=noneNAME=ens18DEVICE=ens18ONBOOT=yesIPADDR=192.168.1.10PREFIX=24GATEWAY=192.168.1.1DNS1=8.8.8.8DNS2=8.8.4.4
Add additional IPs below
IPADDR1=192.168.1.11PREFIX1=24IPADDR2=192.168.1.12PREFIX2=24For IPv6
IPV6ADDR_SECONDARIES="2001:db8::11/64 2001:db8::12/64" - Save the file and restart NetworkManager:sudo systemctl restart NetworkManager
- Verify: ip a
- Ubuntu/Debian (using Netplan):
- Method 1: Temporary IP Alias (Lost on reboot)
- Windows Server
- Graphical Interface:
- Open Network Connections (Control Panel -> Network and Sharing Center -> Change Adapter Settings).
- Right-click the network adapter you want to add the IP to (e.g., "Ethernet") and select "Properties".
- Select "Internet Protocol Version 4 (TCP/IPv4)" and click "Properties".
- Click the "Advanced..." button.
- Under the "IP Addresses" section, click the "Add..." button.
- Enter the new IP address and its Subnet mask.
- Click "Add", then "OK" on all open windows to apply the changes.
- Repeat for IPv6 if needed under "Internet Protocol Version 6 (TCP/IPv6)".
- PowerShell:
- Add an IPv4 address:New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.1.11" -PrefixLength 24
- Add an IPv6 address:New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "2001:db8::11" -PrefixLength 64
- Verify:Get-NetIPAddress -InterfaceAlias "Ethernet"
- Graphical Interface:
- Important Notes:
- Provider Assigned IPs: Only configure IP addresses that have been assigned to your server by ServerHood.com. Attempting to use unassigned IPs will cause connectivity issues.
- Subnet Alignment: Confirm if the additional IP addresses are on the same subnet as your primary IP. If they are on a different subnet, you might need more complex routing configurations. Your provider will clarify this.
- Firewall Rules: After adding new IP addresses, update your server's firewall rules (Iptables, UFW, FirewallD, Windows Firewall) to ensure that any services you want to make accessible on those new IPs are properly allowed.
- DNS Records: If you plan to host new domains or services on these IPs, remember to create or update their respective DNS A (for IPv4) or AAAA (for IPv6) records to point to the new IP address.
- Conclusion
- Adding additional IP addresses gives you greater flexibility in managing your server's network services. Always verify connectivity after making changes and ensure your firewall is updated.