How to add static IPv4 and IPv6 addresses to OpenBSD

Static IP addresses are assigned to devices directly. Such an assignment can be done under the Unix derivative OpenBSD by means of a configuration file. Only a few steps are required for this.

What do I need to consider when configuring a static IP address?

Having a static IP address for your server is beneficial in that it enables customers to locate you more easily through the Domain Name System (DNS). That’s because your IP doesn’t change and has the notable advantage of making the DNS setup easier too. Given the scarcity of IPv4 addresses, it’s recommended that when configuring your IP addresses, you take advantage of the benefits of IPv6 by also storing an IPv6 address.

To configure a static IP address on the OpenBSD operating system, you need to associate the IP addresses you intend to use with your server. If you’re using an IONOS server, you can link these addresses conveniently through the IONOS Cloud Panel. However, to set up a static IPv4 or IPv6 address on OpenBSD, you must have access to the system’s internal terminal. After identifying your network’s name, you can create a file that specifies the server’s IP addresses.

How to assign a static IP address to IONOS servers: A step-by-step guide

After you’ve associated the IP addresses of your choice with your server in the Cloud Panel, you can adjust the settings on the server in just a few steps so that the server can be found at the desired static address.

Step 1: Find out the name of your network interface

To assign IP addresses, you must first identify the name of your network interface. This can be accomplished easily using the ifconfig command built into OpenBSD. Simply open a command line and enter the command to display a list of available network interfaces. Ethernet interfaces typically start with the prefix “en”.

Step 2: Create the file

Next, you’ll need to create a file for assigning the static IPv4 or IPv6 address in OpenBSD at the path /etc/hostname.INTERFACE, replacing INTERFACE with the name of your network interface. To accomplish this, you can use the terminal and any editor of your choice, such as vim.

Step 3: Add file content

Once you’ve created the file, you can configure your IP addresses:

#IPv4
inet IPV4 255.255.255.255
!route add -inet 10.255.255.1 -llinfo -link -static -iface INTERFACE
!route add -inet default 10.255.255.1

#IPv6
inet6 alias IPV6/128
!route add -net ::/0 fe80::1%INTERFACE

Make sure to substitute INTERFACE with the name of your network interface and IPV4 or IPV6 with the desired IP addresses. If you only want to set up an IPv4 address in OpenBSD, you can skip the configuration for IPv6.

Step 4: Restart the system

To activate the changes, a system reboot is necessary. You can do this by using either the Cloud Panel or the terminal command reboot.

Step 5: Check if configuration was successful

To verify that the static IP address change was successful, open the terminal and use the ifconfig command to display information about your network interfaces and their corresponding IP addresses.

Tip

If you don’t have your own server yet, consider checking out IONOS’ affordable Dedicated Server. You can apply the instructions here directly to our dedicated servers.

We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.