Network Setup - MidnightBSD/src GitHub Wiki

For most users, who only have IPv4 at home, it's often sufficient to setup DHCP.

For example, if you have an Intel gigabit NIC, placing the following in /etc/rc.conf is sufficient.

ifconfig_em0="DHCP"

Static IP Address with hostname

defaultrouter="70.91.226.206"
hostname="[stargazer.midnightbsd.org](http://stargazer.midnightbsd.org/)"
ifconfig_ix0="70.91.226.201  netmask 255.255.255.248"

IPv6

ipv6_enable="YES"
ipv6_defaultrouter="2001:470:1f10:1c7::1"
ifconfig_em1_ipv6="inet6 2001:470:1f11:1c7::2/64"
or 
ifconfig_em1_ipv6="inet6 2001:470:1f11:1c7::2 prefixlen 64"

Some providers will give you a prefixlen 64 but a default router outside of the range. You may need to use a prefixlen 56 in this scenario. (OVH is a good example)

if you need to do a static route in IPv6:

ipv6_static_routes="ovh1"
ipv6_route_ovh1="<ip address here> -iface ix0"

Static IP alias

Add a second IP address to the same server. This can be useful for web servers, or systems with jails.

ifconfig_ix0_alias0="inet 70.91.226.202 netmask 255.255.255.255"

Stability issues

Some wired network adapters have issues with their hardware offload capabilities. Trying the following settings individually or as a group can often help.

-lro -tso -rxcsum -txcsum -txcsum6

Add these to the end of your ifconfig_em0 line...

e.g.

ifconfig_em0="DHCP -lro -tso -rxcsum -txcsum -txcsum6"

This is more likely to come up when your system is acting as a router or firewall.

Link Aggregation

For instance, you have two intel gigabit NIC ports em0 and em1

cloned_interfaces="lagg0"

ifconfig_lagg0="laggproto lacp laggport em0 laggport em1 70.91.226.201 netmask 255.255.255.248"

Add an ipv6 alias

ifconfig_lagg0_alias1="inet6 2001:4978:1fc::1/64"

WiFi

This example uses a realtek usb device

in /etc/rc.conf:

ifconfig_wlan0="WPA SYNCDHCP"

wlans_urtwn0="wlan0"

in /etc/wpa_supplicant.conf

network={
    ssid="NetworkName"
    psk="ThePassword"
}

Dual Stack

There are a few configuration options for using IPv4 and IPv6 together.

Building on the previous example,

ifconfig_em0="DHCP"
ifconfig_em0_ipv6="inet6 accept_rtadv"
rtsold_enable="YES"

This will allow anything advertising router solicitations to work. Sometimes, IPv6 uses DHCP also. This configuration will work with many setups including AWS and VMWare esxi.

Install the dual-dhclient package

mport install dual-dhclient

In /etc/rc.conf,

rtsold_enable="YES"

ifconfig_DEFAULT="SYNCDHCP accept_rtadv"

dhclient_program="/usr/local/sbin/dual-dhclient"