Article overview

Help article

Adding an IPv4 or IPv6 address in FreeBSD

When you order an extra IPv4 address or add an extra IPv6 address to your IP addresses via the TransIP control panel, these cannot be automatically added to your VPS via DHCP. Additional IP addresses are added manually to the network interfaces.

In this article, we explain how you can statically add an extra IPv4 or IPv6 address to your FreeBSD VPS. For this, an extra IPv4 and/or IPv6 address is required (depending on which you'd like to add / configure). Don't have an extra address yet? The following articles explain how you can get one:

 

Click here for a complete overview of all our tutorials for adding an extra or static IPv4 or IPv6 address to various Linux distros. For adding an IPv4 or IPv6 address to a Windows VPS, see this article.

  • This manual is about public IP addresses. In this manual, you will find more information about setting up internal addresses (for your private network).
  • A VPS includes 1 IPv4 address by default, but you can expand this to a maximum of 10 IPv4 addresses via the control panel. A maximum limit of 20 IPv4 addresses applies to the VPSs of the PRO series.

  • Each VPS has a /64 IPv6 range at its disposal by default, where IP addresses can be added as desired. A /64 IPv6 range contains a total of 18,446,744,073,709,551,616 IP addresses, so the likeliness that you will not have enough is quite small! The default gateway falls outside of the /64 range so as netmask you always use a /48 range.


Adding an IPv4 address in FreeBSD

 

Step 1 

Connect to the VPS via the VPS console or via SSH.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is vtnet0 in this example.    


 

Step 3 

Now add the extra IPv4 address in the network interfaces. First, open the network configuration file:

nano /etc/rc.conf

A configuration file opens, and you modify the following:

  • Add the gateway (this is replaced by your own gateway IP): 
    defaultrouter="149.210.204.1"
  • Change the ifconfig_vtnet0 = "DHCP" line to a manually configured IP: 
    ifconfig_vtnet0="inet 149.210.202.105 netmask 255.255.255.0"
  • Add the extra IPs in the lines below, making sure that the _alias0 have consecutive numbers. 
    ifconfig_vtnet0_alias0="inet 149.210.202.105 netmask 255.255.255.255"
    ifconfig_vtnet0_alias1="inet 149.210.202.118 netmask 255.255.255.255"

Here, defaultrouter is the IP address of the gateway, which for your IP address can be found in the control panel. The netmask is 255.255.255.0 for the main IP address, you set this to 255.255.255.255 for all 'extra' IP addresses. An alternative possibility is to add all aliases via the following example: 

ifconfig_vtnet0_aliases="\
   inet 149.210.202.105/24 \
   inet 149.210.202.118/24 \

Save the changes and exit nano (ctrl + x > y > enter).   


 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

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

 

Step 5

If you run ifconfig -a again you will see the newly added IPv4 address. You can test this IP address by performing a ping test from another computer / IP. Repeat the above steps if you want to add more IP addresses.  


Adding an IPv6 address in FreeBSD

 

Step 1 

Connect to the VPS via the VPS console or via SSH.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is vtnet0 in this example.  


 

Step 3 

Now add the extra IPv6 address in the network interfaces. First, open the network configuration file:

sudo nano /etc/rc.conf

In the opened configuration file, adjust the following:

  • Change the ifconfig_vtnet0_ipv6 line to a manually configured IP:
    ifconfig_vtnet0_ipv6="inet6 2a01:7c8:aab8:77::1/48"
  • Add the extra IPs in the lines below, making sure that the _alias0 have consecutive numbers.
    ifconfig_vtnet0_ipv6="inet6 2a01:7c8:dead:beef::2/48"
    ifconfig_vtnet0_alias0="inet6 2a01:7c8:dead:beef::1234/48"  
    
  • An alternative possibility is to add all aliases via the following example: 

    ifconfig_vtnet0_aliases=" \
       inet6 2a01:7c8:aab8:77::1337/48 \
       inet6 2a01:7c8:aab8:77::13:17/48 \
    

Save the changes and exit nano (ctrl + x > y > enter).   


 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

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

 

Step 5 

If you run ifconfig -a again you will see the newly added IPv6 address. You can test this IP address by performing a ping test from another computer / IP. 

Repeat the above steps if you want to add more IP addresses. 


 

Should you have any questions left regarding this article, do not hesitate to contact our support department. You can reach them via the ‘Contact Us’ button at the bottom of this page.

If you want to discuss this article with other users, please leave a message under 'Comments'.

Has this article been helpful?

Create an account or log in to leave a rating.

Comments

Create an account or log in to be able to leave a comment.