Setting up NetBSD

Network setup

dynamically

hostname SHORT
ifconfig xennet0 inet x.x.x.x/xx up
route add default x.x.x.x

at boot time

echo SHORT > /etc/myname
echo inet x.x.x.x/xx up > /etc/ifconfig.xennet0
echo x.x.x.x > /etc/mygate
#service network restart

static name resolution

vi /etc/hosts

127.0.0.1 localhost
x.x.x.x   SHORT.example.local SHORT
x.x.x.x   gw

DNS

cat > /etc/resolv.conf <<EOF
#search example.local
nameserver 208.67.222.222
nameserver 208.67.220.220
EOF

SSHD

See SSHD.

Scripted post-installation

This is all provided by those scripts

mkdir -p ~/bin/
cd ~/bin/
ftp -a http://pub.nethence.com/bin/netbsdconf.ksh.txt
ftp -a http://pub.nethence.com/bin/netbsdconfpkg.ksh.txt
cp -i netbsdconf.ksh.txt netbsdconf.ksh
cp -i netbsdconfpkg.ksh.txt netbsdconfpkg.ksh
chmod +x netbsdconf.ksh netbsdconfpkg.ksh
./netbsdconf.ksh > netbsdconf.log
./netbsdconfpkg.ksh > netbsdconfpkg.log

ls -lF /etc/openssl/certs/
mozilla-rootcerts install

Finish-up manually

define a password for root just in case you need a least amount of physical security (by that I mean console login) and avoid getting a warning about it every day

passwd

tune the daily report AT THE END — otherwise you would get sendmail: fatal: root(0): No recipient addresses found in message header

cp -pi /etc/daily /etc/daily.dist
vi /etc/daily

echo
time nice /root/backup.ksh
time nice /root/upload.ksh
echo

echo local ping scan
/usr/pkg/bin/nmap -sn -oG - CIDR
echo

echo arp
arp -a
echo

echo remote ping scan
/usr/pkg/bin/nmap -sn -oG - SOME-CIDR
echo

echo remote scan
echo /usr/pkg/bin/nmap -sTUV SOME-CIDR
time /usr/pkg/bin/nmap -sTUV SOME-CIDR
#-Pn -T4 -p0-65535
echo

echo who\'s who
w -w
echo

echo processes
top -b 10
ps auxww | sort
echo

echo sockstat
sockstat -4 -l
sockstat -6 -l
echo

echo netstat
netstat -a -f inet,inet6
netstat -rn -f inet,inet6
echo

tune the weekly report

cp -pi /etc/weekly /etc/weekly.dist
vi /etc/weekly

#self verbose
/usr/pkg/bin/certbot certificates
/usr/pkg/bin/certbot renew && /root/RELOAD-SSL

fix-up cron jobs

crontab -e

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/local/bin

#*/10   *       *       *       *       /usr/libexec/atrun
0       3       *       *       *       /usr/bin/newsyslog
30      5       1       *       *       /bin/sh /etc/monthly 2>&1 | tee /var/log/monthly.out | sendmail -t

enable indexing (check /etc/weekly –> rebuild_locatedb)

ls -lF /var/db/locate.database
su -m nobody -c /usr/libexec/locate.updatedb 2>/dev/null

Operations

make sure you are clean

ps auxww
netstat -an -f inet,inet6
cat /etc/resolv.conf

vi ~/log

tail -F /var/log/messages

chmod +x log

Optional

Syslogd tuning

for easy troubleshooting

cp -pi /etc/syslog.conf /etc/syslog.conf.dist                     
vi /etc/syslog.conf

.err;kern.*;auth.notice;authpriv.none;mail.crit         /dev/console
*.emerg                                                 *
*.info                                                  /var/log/messages

or if this is an mail exchanger, maybe

*.err;kern.*;auth.notice;authpriv.none;mail.crit        /dev/console
*.emerg                                                 *
mail.info                                               /var/log/maillog
*.info;mail.none                                        /var/log/messages

fix the permissions and apply

-rw-------   1 root    wheel    105K May  3 15:15 /var/log/messages

service syslogd restart

NTP

eventually setup ntp – not sure this is needed for xen guests

mv -i /etc/ntp.conf /etc/ntp.conf.dist
sed '/^$/d;/^#/d;' /etc/ntp.conf.dist > /etc/ntp.conf
vi /etc/ntp.conf

#server          ntp.obspm.fr
#server          ntp1.online.net
#server          ntp2.online.net

server 0.ru.pool.ntp.org
server 1.ru.pool.ntp.org
server 2.ru.pool.ntp.org
server 3.ru.pool.ntp.org

vi /etc/rc.conf

ntpdate=yes ntpdate_flags="-u -b -s"
ntpd=yes    ntpd_flags=""

grep ^server /etc/ntp.conf
ntpdate -u ...
service ntpd start
ntpq -p

the ntpdate service looks at ^server into /etc/ntp.conf at boot time.

Outgoing messages

eventually define a smarthost and fix your origin so the bounces are also sent to your MX (assuming you have setup an FQDN in /etc/myname, otherwise fix with myhostname = or mydomain =),

cd /etc/postfix/
mv -i main.cf main.cf.dist
sed '/^[[:space:]]*#/d; /^[[:space:]]*$/d' main.cf.dist > main.cf
vi main.cf

relayhost = SMARTHOST
myhostname = lala.example.net
myorigin = lala.example.net
mydomain = example.net

service postfix restart

and setup an email alias for root,

mv -i /etc/mail/aliases /etc/mail/aliases.dist
sed '/^[[:space:]]*#/d; /^[[:space:]]*$/d' /etc/mail/aliases.dist > /etc/mail/aliases
vi /etc/mail/aliases

root:       REAL_EMAIL

newaliases
tail -F /var/log/maillog &
date | mailx -s `hostname` root
mailq

Resources

Setting up NetBSD https://users.ics.aalto.fi/kaip/netbsd.html


Nethence | Pub | Lab | Pbraun | SNE Russia