9

I need one more loopback interface in my OpenBSD 6.1, with the IP address 127.0.0.2.

I can create it by hand with the command:

ifconfig lo1 127.0.0.2

And to have it at boot time, I just inserted that command into /etc/rc.local.

I have researched for a more standard way to do that, was not successful.

Having it in /etc/rc.local also means I only have that interface late in the boot process.

How may I configure it in a cleaner "OpenBSD" way?

2 Answers 2

10

As hinted at in lo(4), you may create /etc/hostname.lo1:

inet 127.0.0.2 255.0.0.0

This will create the lo1 interface when the boot process runs /etc/netstart. With that file in place, you may also set up the interface without rebooting through

$ doas sh /etc/netstart lo1

The interface is reported as

lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768
        index 4 priority 0 llprio 3
        groups: lo
        inet 127.0.0.2 netmask 0xff000000

by ifconfig.

For further info, see hostname.if(5), netstart(8) and ifconfig(8).

1
  • 2
    Thanks for all the help, I am getting my feet wet in OpenBSD in a personal netbook as a pilot/(re)introduction to the system. Commented Jun 14, 2017 at 8:36
0

Unless you have a reason for this to be an additional network interface, note that you do not have to have a second interface just in order to have a second IP address in 127.0.0.0/8. You can add the second IP address to the existing loopback interface:

# echo >> /etc/hostname.lo0 inet alias 127.0.0.2 255.255.255.255
# 

Note that the alias gets a tighter (/32) netmask; cf. https://www.openbsd.org/faq/faq6.html#Setup.aliases.

NB: Be aware that if you use ifconfig -a, it only lists each interface's first address. You can use ifconfig -A instead to see all addresses, including aliases.

1
  • I defined a interface to give it to some particular software at the time. Switched back to freebsd. Commented Mar 23, 2019 at 19:21

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .