My NetBSD cheat sheet

Various tasks I use to do on my NetBSD systems.

Specify an IP address for your NIC

$ cat /etc/ifconfig.fxp0
inet netmask 0xffffff00

Specify a gateway

$ cat /etc/mygate

Add an IP alias on a NIC

$ cat /etc/ifconfig.fxp0
inet netmask 0xffffff00
inet netmask 0xffffffff alias

NIC will retrieve its IP address via DHCP

$ cat /etc/ifconfig.re0
!dhcpcd $int

Add a static route when bringing up NIC

$ cat /etc/ifconfig.re0
!dhcpcd $int
!route -n add -net

Specify a media type for a NIC

$ cat /etc/ifconfig.re0
media 100baseTX up
!dhcpcd $int

Add an IPv6 address to a NIC

$ cat /etc/ifconfig.re0
media 100baseTX up
!dhcpcd $int
inet6 2001:dead:beef:1::1 prefixlen 64

Very basic pf rules for NAT and firewalling

$ cat /etc/pf.conf

nat on $ext_if from !($ext_if) -> ($ext_if:0)

# allow outgoing traffic (S/A is implied)
pass out on $ext_if
# block all incoming traffic
block in log on $ext_if

Setup WPA WiFi client

# wpa_passphrase WPA-WiFi-SSID my-strong-passphrase >> /etc/wpa_supplicant.conf
$ grep wpa /etc/rc.conf
wpa_supplicant_flags="-B -iath0 -c/etc/wpa_supplicant.conf"
# /etc/rc.d/wpa_supplicant start

Upgrade the system with binaries

# cp /netbsd /netbsd.old
# tar zxvfp kern-MONOLITHIC.tgz -C /
# sync; sync
# shutdown -r now
# for i in base comp games man misc modules tests text xbase xcomp xetc xfont xserver; do tar zxvfp $i.tgz -C /;done
# mkdir /tmp/temproot
# tar zxvfp etc.tgz -C /tmp/temproot
# postinstall -s /tmp/temproot check
# # copy postinstall's requirements
# etcupdate -s /tmp/temproot
# shutdown -r now

Upgrade the system with sources

# cd /usr/src
# ./ -O ../obj -T ../tools -j#jobs -U distribution
# cd /usr/src
# ./ -O ../obj -T ../tools -j#jobs kernel=YOUR_KERNEL
# cd /usr/src
# cp /netbsd /netbsd.old
# cp /usr/obj/sys/arch/YOUR_ARCH/compile/YOUR_KERNEL/netbsd /
# shutdown -r now
# cd /usr/src
# ./ -O ../obj -T ../tools -U install=/
# /usr/sbin/etcupdate -s /usr/src

Adobe Flash

# echo "procfs /emul/linux/proc procfs ro,linux" >> /etc/fstab
# mount /emul/linux/proc
# cd /usr/pkgsrc/www/nspluginwrapper
# make install
# cd /usr/pkgsrc/multimedia/ns-flash
# make install
$ nspluginwrapper -i /usr/pkg/lib/netscape/plugins/

Mount / umount an iso image

# vnconfig -v -c /dev/vnd0d output.iso
# mount -t cd9660 /dev/vnd0a /mnt
# [...]
# umount /mnt
# vnconfig -u vnd0d

To specify the order of network interfaces creation at boot time

  • Disable auto_ifconfig
    # grep auto_ifconfig /etc/rc.conf

  • Define their order of creation
    # grep net_interfaces /etc/rc.conf
    net_interfaces='wm0 tap0 tap1 bridge0 bridge1'

Comment by Matthieu at lunch time on Wednesday, February 13th, 2013

You also need to add to rc.conf:

Need /usr mounted in order to setup WiFi during boot.

critical_filesystems_local="${critical_filesystems_local} /usr"

Comment by achowe Sunday evening, May 26th, 2013
Add a comment