Home > Networking > Add additional IPs

Add additional IPs

January 20, 2009 Posted by KP

I made some mistakes when adding additional IPs for my new server and was locked out twice. Here are some tips to avoid those errors.

Usually, ISP will add all IPs for you. I didn’t have to do it by myself until this month. Anyway, they must have made the main IP working, these two lines should be present in /etc/rc.conf.

Note: All IPs are fake and make no sense at all.

ifconfig_re0=”inet 100.100.100.100 netmask 255.255.255.240″
defaultrouter=”100.100.100.96″


Don’t touch these two lines, although additional IPs can be added into the first line (elegant solution), it’s dangerous if you are working remotely. Let’s do it with the standard way: Each IP uses one line, they look like:

ifconfig_re0_alias0=”inet 100.100.100.101 netmask 255.255.255.255″
ifconfig_re0_alias1=”inet 100.100.100.102 netmask 255.255.255.255″
ifconfig_re0_alias2=”inet 100.100.100.103 netmask 255.255.255.255″
ifconfig_re0_alias3=”inet 100.100.100.104 netmask 255.255.255.255″
ifconfig_re0_alias4=”inet 100.200.200.200 netmask 255.255.255.240″
ifconfig_re0_alias5=”inet 100.200.200.201 netmask 255.255.255.255″
ifconfig_re0_alias6=”inet 100.200.200.202 netmask 255.255.255.255″
ifconfig_re0_alias7=”inet 100.200.200.203 netmask 255.255.255.255″

re0 must be changed to your own network interface.

If the additional IPs are in the same subnet of main IP, netmark must be 255.255.255.255. To add IPs in a different subnet, netmask for the first IP is the subnet’s netmark, the following IPs use 255.255.255.255.

How to know the netmark? When IPs are given to you, it’s usually in a format like: 100.100.100.100/28.

/28 NETMASK = 255.255.255.240
/27 NETMASK = 255.255.255.224
/26 NETMASK = 255.255.255.192
/25 NETMASK = 255.255.255.128
/24 NETMASK = 255.255.255.0

After you finish rc.conf, restart the network, the following command must be issued in one line:

# /etc/rc.d/netif restart && /etc/rc.d/routing restart

Here is a helpful guide in more detail.



Related Posts:

Filed Under: Networking

Leave a Comment

(required)
(will not be published, required)

* Copy this password:

* Type or paste password here:






Archives

Links