rss logo

Configure network interfaces on OpenBSD

OpenBSD Logo

Intro

Configuration

  • OS: OpenBSD 7.3

Installing

  • Get interface name:
openbsd# ifconfig
  • we need to create a /etc/hostname."interface_name" file for each interface, contening this information:
address_family address netmask broadcast [other options]

Settings

  • dhcp: put the interface in dhcp mode
  • address_family: inet for IPv4
  • address: ip address
  • netmask: network mask
  • NONE: No broadcast address

Examples

  • Set gateway:
# echo "192.168.1.1" > /etc/mygate
  • Set em0 interface in dhcp:
# echo "dhcp" > /etc/hostname.em0
  • Set em1 interface in static:
inet 192.168.1.2 255.255.255.0 NONE
  • Set a vlan10 interface on em1 interface:
inet 172.21.0.31 255.255.255.0 NONE vlan 10 vlandev em1
  • Set DNS:
echo "nameserver 192.168.1.254" > /etc/resolv.conf
  • To take this changes into consideration we need to execute:
# sh /etc/netstart
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :

contact mail address