📜 ⬆️ ⬇️

IP aliasing - FreeBSD

Usually, the server is not installed for the sake of one single site, but several are placed at once. Or even set in case it is a server for virtual hosting.

You can of course hang all the sites on one IP, but this is in my opinion not kosher. Accordingly, we need to bind a certain number of IP addresses to the server. For this, IP aliasing will be used.


The binding of IP aliases is performed through the beloved ifconfig .
')
General syntax:

ifconfig lo0 alias inet IP _ADDRESS netmask NET_MASK

Example:

ifconfig lo0 alias inet 217.23.45.5 netmask 255.255.255.255

Use the loopback interface back - lo0 is not at all necessary, aliases can be raised on the network interface, for example, em0 or on the VLAN if they are used ...

Next, you need to force our aliases to rise automatically at system startup. To do this, go to /etc/rc.conf and write the following:

ifconfig_lo0_alias0 = "inet IP _ADDRESS netmask NET_MASK"

Example:

ifconfig_lo0_alias0 = "inet 217.23.45.5 netmask 255.255.255.255"

Note that the records of synonyms must begin with alias0 and go on in a certain order - alias0, alias1, ..., alias10.

Now these IPs raised as aliases can be used in the system at your discretion.

If you need to remove the IP alias from the interface, then you can comment out the corresponding line in /etc/rc.local and restart the system =). Or you can use ifconfig:

ifconfig lo0 -alias IP _ADDRESS

Example:

ifconfig lo0 -alias 217.23.45.5

You do not need to specify a mask. IP is enough.

Source: https://habr.com/ru/post/43778/


All Articles