FreeBSD 11.2 初期セットアップ

2019/04/22

◾️OSのアップデート
# freebsd-update fetch
# freebsd-update install

◾️Portsのアップデート
# portsnap fetch
# portsnap extract

◾️ssh起動
# vim /etc.rc.conf
sshd_enable="YES"

◾️vimのインストール
# /usr/ports/editors/vim
# make install clean

◾️一般ユーザをwheeelグループに追加してsu -できるようにした
# vim /etc/group

◾️lsofのインストールした
# cd /usr/ports/sysutils/lsof
# make install clean

◾️/usr/local/etc/ipfw.rulesにファイヤーウォールルールを定義した
# vim /etc.rc.conf
firewall_enable="YES"
firewall_script="/usr/local/etc/ipfw.rules"

# vim /usr/local/etc/ipfw.rules
#! /bin/sh
IPF="ipfw -q add"
ipfw -q -f flush
#loopback
$IPF 10 allow all from any to any via lo0
$IPF 20 deny all from any to 127.0.0.0/8
$IPF 30 deny all from 127.0.0.0/8 to any
$IPF 40 deny tcp from any to any frag
# statefull
$IPF 50 check-state
$IPF 60 allow tcp from any to any established
$IPF 70 allow all from any to any out keep-state
$IPF 80 allow icmp from any to any
# open port ssh (22), http (80), dns (53) , https(443)
$IPF 100 allow tcp from any to any 22 in
$IPF 105 allow tcp from any to any 22 out
$IPF 110 allow tcp from any to any 25 in
$IPF 115 allow tcp from any to any 25 out
$IPF 120 allow udp from any to any 53 in
$IPF 125 allow tcp from any to any 53 in
$IPF 130 allow udp from any to any 53 out
$IPF 135 allow tcp from any to any 53 out
$IPF 140 allow tcp from any to any 80 in
$IPF 145 allow tcp from any to any 80 out
$IPF 150 allow tcp from any to any 443 in
$IPF 155 allow tcp from any to any 443 out
# deny and log everything
$IPF 900 deny log all from any to any

◾️仮装端末ttyv1からttyv7までをコメントアウト
# vim /etc/ttys

◾️posrfixとCyrus SASL2とCyrus saslauthdをインストール 参考リンク
#cd /usr/ports/security/cyrus-sasl2
# make BATCH=yes WITHOUT_OTP=yes WITH_BDB=yes install clean
# rehash
# cd /usr/ports/security/cyrus-sasl2-saslauthd
# make BATCH=yes WITH_BDB=yes install clean
# cd /usr/ports/mail/postfix
# make WITH_SASL2=yes WITH_TLS=yes WITH_BDB=yes install clean
※Would you like to activate Postfix in /etc/mail/mailer.conf [n]? # <= エンター応答(mailer.conf は後で手動で書き換えるので "n" 応答)
# rehash
# cd
※参考リンクを元にごにょごにょする

◾️postfixでmtn-dnsへのリレー設定した
# vim /usr/local/etc/postfix/main.cf

◾️logwatchの設定とcrontab設定をした
# cd /usr/ports/sysutils/logwatch
# make install

◾️時間のズレを直す
# vim /etc/ntp.conf
# ntpdate 同期先ntpサーバアドレス
# vim /etc.rc.conf
ntpd_enable="YES"

◾️dhcpでresolv.confが上書きされないようにする
# vim /etc/dhclient.conf
supersede domain-name "hoge.com";
supersede domain-name-servers host.hoge.com;



関連記事

シェア訴求文言

-FreeBSD
-