Linux / FreeBSD: Multiple IP Addresses on One Interface

‮w//:sptth‬ww.lautturi.com
Linux / FreeBSD: Multiple IP Addresses on One Interface

On a Linux or FreeBSD system, you can assign multiple IP addresses to a single network interface using the following steps:

  1. Determine the name of the network interface you want to configure. You can use the ifconfig command to list all of the available interfaces on your system.

  2. Edit the network configuration file for the interface. The configuration file for each interface is typically located in the /etc/sysconfig/network-scripts directory. For example, the configuration file for the eth0 interface would be /etc/sysconfig/network-scripts/ifcfg-eth0.

  3. Add the additional IP addresses to the configuration file. In the configuration file, add a line for each additional IP address you want to assign to the interface. The line should be in the following format:

IPADDR_X=IP_ADDRESS

Replace X with a number starting at 2, and IP_ADDRESS with the actual IP address you want to assign. For example, to add the IP address 192.168.1.10 to the eth0 interface, you would add the following line to the ifcfg-eth0 file:

IPADDR_2=192.168.1.10
  1. Restart the network service. Once you have added the additional IP addresses to the configuration file, you will need to restart the network service for the changes to take effect. On a Linux system, you can use the systemctl command to restart the network service. For example:
systemctl restart network

On a FreeBSD system, you can use the service command to restart the network service. For example:

service netif restart

After the network service has been restarted, the additional IP addresses should be assigned to the specified interface. You can use the ifconfig command to verify that the IP addresses have been added to the interface.

Created Time:2017-10-29 22:08:54  Author:lautturi