Network settings live in /etc/rc.conf. The examples use the documentation ranges 192.0.2.0/24 and 2001:db8::/32 and the interface em0; substitute your own values (ifconfig lists your interfaces).
1Static IPv4
sysrc ifconfig_em0="inet 192.0.2.10/24"
sysrc defaultrouter="192.0.2.1"
# an extra address (alias):
sysrc ifconfig_em0_alias0="inet 192.0.2.11/32"
Or for DHCP: sysrc ifconfig_em0="DHCP".
2Static IPv6
sysrc ifconfig_em0_ipv6="inet6 2001:db8::10 prefixlen 64"
sysrc ipv6_defaultrouter="2001:db8::1"
For automatic configuration from router advertisements (SLAAC) instead:
sysrc ifconfig_em0_ipv6="inet6 accept_rtadv"
sysrc rtsold_enable=YES
3Apply the changes
Applying network changes over SSH can cut you off, so do this from the console or be ready to recover.
service netif restart && service routing restart
4DNS with resolv.conf
Name servers are listed in /etc/resolv.conf. On DHCP systems this file is managed by resolvconf; to set servers permanently, configure /etc/resolvconf.conf and regenerate.
# /etc/resolv.conf
search example.org
nameserver 192.0.2.53
nameserver 2001:db8::53
# or via resolvconf:
echo 'name_servers="192.0.2.53 2001:db8::53"' >> /etc/resolvconf.conf
resolvconf -u
5A local caching resolver with local_unbound
The base system includes Unbound for local caching and DNSSEC validation. Enabling it rewrites resolv.conf to point at 127.0.0.1 and forwards to your previous servers.
sysrc local_unbound_enable=YES
service local_unbound start
cat /etc/resolv.conf
6Hostname
sysrc hostname="host.example.org"
hostname host.example.org