4

Question: How to set static IP in OpenBSD/LibertyBSD?

Backstory: I recently purchased a *BSD VPS and have been having some issues with networking. How do I set the IP address?

1
  • Did you check the OpenBSD docs at openbsd.org/faq/faq6.html ? AFAIK there's a pretty good explanation. Commented Sep 17, 2019 at 5:19

2 Answers 2

4

If your network device is en0, and you want to configure it with the persistent static IP address 10.1.2.3 and the netmask 255.255.255.0, then you create /etc/hostname.en0 with the contents

inet 10.1.2.3 255.255.255.0

This will take effect upon rebooting (when /etc/netstart is run; see netstart(8)).

See also the hostname.if(5) manual, and the networking section of the OpenBSD FAQ.

2
  • What if it is not en0? I believe I selected vio0 as the network interface during installation. </br> Also, do I need root access to edit etc/hostname.en0? Commented Sep 17, 2019 at 6:12
  • 1
    @WildForest33349 Then you simply use vio0 in place of en0 in my answer. You have to be root to make changes like these, yes. I'm not aware of any Unix that allows you to change network configuration without root access. The system installation process should have created /etc/hostname.vio0 already (if not, you may just create it), so you just need to change its contents. Commented Sep 17, 2019 at 6:50
1

If I recall properly try using ifconfig:

# ifconfig [network interface] inet [address] netmask [netmask]

You will need root so execute su - first.



To follow @Kusalananda's post if the address is 10.1.2.3 and the netmask 255.255.255.0 on the network interface vio0 you should be able to execute the following:

# ifconfig vio0 inet 10.1.2.3 netmask 255.255.255.0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.