何故かFreeBSDをいじりたくなり、HP2133にFreeBSDをインストールしてみた。
インストール完了後、Fluxboxや各ツールの設定において設定ファイルを直接いじる事が多いものの、想定どおりの動作をするので大変満足。HP2133はこのままFreeBSDで運用する事になった。
2.2.8-RELEASEや4.1以来のFreeBSD。十数年ぶり。
ぷらっとホームで購入したデーモン君人形や、書店で購入したアスキー社のBSDマガジンは、まだ埼玉の家に有るはず。
今度行ったら引っ張り出してみるか。
以下は、インストール後に打ったuname -aの出力内容。(hostnameはぼかしてある)
uname -a FreeBSD ********** 9.3-RELEASE FreeBSD 9.3-RELEASE #0 r268512: Fri Jul 11 03:13:02 UTC 2014 root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC i386
対象機器:HP2133 (RAM: 1GB、HDD: SATA 160GB、CPU:VIA C7-M ULV 1.2GHz)
OS:FreeBSD 9.3
以下はインストールした各ツール。tcshとinetdとwifimgr以外は、Ubunutu Server 14.04の時と同じ。
シェル: tcsh
ターミナルエミュレータ: eterm
Window Manager: fluxbox
システムの簡易モニタリングツール: gkrellm
FTPサーバ: vsftpd
サーバ管理ツール: webmin
スーパーサーバ: inetd
シリアル接続用ターミナルエミュレータ: ckermit
無線LANクライアント: wifimgr
Webブラウザ: Firefox
ゲーム:nethack、xbill
Fluxbox上で動作するアプリ等: leafpad、xpad、plan、xeyes、xcalc
フォント: ja-font-ipa-00303_6
以下は、OSや各ツールのインストール直後に設定した内容。備忘録の為に残しておく。
セキュリティ関連の設定が中心。
Googleで検索し、アクセスした各サイトの記載内容から自分の環境に合ってそうなものを拝借し設定した。
インストール直後の段階ではsudoが入っていない。
pkg install sudoを叩いてsudoをインストール。
/etc/groupファイル内のwheelグループに自分のアカウント名を追加。
wheel:*:0:root,自アカウント :
続いてvisudoコマンドを叩き、以下の行の#を削除しコメントアウトから外す。
: ## Uncomment to allow members of group wheel to execute any command # %wheel ALL=(ALL) ALL #この行の行頭にある"#"を削除 :
以降は、suでrootに移行せずsudoを使用。
/etc/rc.conf
サービスやデバイスの有効化設定。
allscreens_flags="MODE_279" # CUIの解像度をHP2133に合わせた hostname="***********" # 自機のホスト名 keymap="us.iso.kbd" # USキーボード使用 ifconfig_bge0="DHCP" wlans=run0="wlan0" # WLANインターフェースをwlan0とした ifconfig_wlan0="WPA DHCP" dbus_enable="YES" sshd_enable="YES" # sshdの有効化 ntpd_enable="YES" # ntpdの有効化 fusefs_enables="YES" inetd_enable="YES" # inetdの有効化 webmin_enable="YES" # webminの有効化 vsftpd_enable="YES" # vsftpdの有効化 firewall_enable="YES" # ipfwの有効化 firewall_script="/etc/rc.ipfw" # ipfwルール設定用スクリプトのパス指定
/etc/inetd.conf
スーパーサーバの設定。ftpとsshのみコメントアウト。
ftp stream tcp nowait root /usr/libexec/ftpd ftpd -I #ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd -I ssh stream tcp nowait root /usr/sbin/sshd ftpd -i -4 #ssh stream tcp6 nowait root /usr/sbin/sshd ftpd -i -4 #telnet stream tcp nowait root /usr/libexec/telnetd telnetd #telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd #shell stream tcp nowait root /usr/libexec/rshd rshd #shell stream tcp6 nowait root /usr/libexec/rshd rshd #login stream tcp nowait root /usr/libexec/rlogind rlogind #login stream tcp6 nowait root /usr/libexec/rlogind rlogind #finger stream tcp nowait/3/10 nobody /usr/libexec/fingerd fingerd -k -s #finger stream tcp6 nowait/3/10 nobody /usr/libexec/fingerd fingerd -k -s :
/etc/ttys
使用しない仮想コンソールの無効化。ttyv1からttyv8まで、onからoffに修正。
console none unknown off secure # ttyv0 "/usr/libexec/getty Pc" xterm on secure # Virtual terminals ttyv1 "/usr/libexec/getty Pc" xterm off secure ttyv2 "/usr/libexec/getty Pc" xterm off secure ttyv3 "/usr/libexec/getty Pc" xterm off secure ttyv4 "/usr/libexec/getty Pc" xterm off secure ttyv5 "/usr/libexec/getty Pc" xterm off secure ttyv6 "/usr/libexec/getty Pc" xterm off secure ttyv7 "/usr/libexec/getty Pc" xterm off secure ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure :
/etc/ssh/sshd_config
sshで使用するポートおよびsshログイン方法の変更。
Port 10022 # 22から10022に修正 : Protocol 2 # sshバージョン2に固定設定 : PermitRootLogin no # ルートアカウントでのログインNG : PasswordAuthentication yes # ログイン時のパスワード必要 : PermitEmptyPasswords no # 空パスワードでのログイン不可 : ServerKeyBits 1024 # 暗号鍵のキー長を1024bitsに設定 : AllowUsers hoge # sshログインのユーザ名を指定。この行は新規に追加。
/etc/rc.ipfw
ipfwのルール設定用スクリプト。ファイル名は/etc/rc.conf内に記載した"firewall_script="の内容と合っていれば何でも良い。
#!/bin/sh IPF="ipfw -q add" # ipfwを初期化 ipfw -q -f flus # ループバックインターフェースを介した通信用 $IPF 15 allow ip from any to any via lo0 # いわゆる"Martian IP Address"を拒否 $IPF 20 deny ip from 0.0.0.0/8 to any #$IPF 21 deny ip from 127.0.0.0/8 to any $IPF 22 deny ip from 172.16.0.0/16 to any $IPF 23 deny ip from 224.0.0.0/4 to any $IPF 24 deny ip from 240.0.0.0/4 to any # 既に確立している通信は許可 $IPF 30 check-state $IPF 31 allow tcp from any to any established $IPF 32 allow all any to any out keep-state $IPF 33 allow icmp from any to any # FTP用 $IPF 100 allow tcp from any to any 20 in $IPF 101 allow tcp from any to any 20 out $IPF 102 allow tcp from any to any 21 in $IPF 103 allow tcp from any to any 21 out $IPF 104 allow tcp from any to any 4000-4009 in $IPF 105 allow tcp from any to any 4000-4009 out # SSH用 $IPF 110 allow tcp from any to any 10022 in $IPF 111 allow tcp from any to any 10022 out # DNS用 $IPF 120 allow tcp from any to any 53 in $IPF 121 allow tcp from any to any 53 out $IPF 123 allow udp from any to any 53 in $IPF 124 allow udp from any to any 53 out # HTTP用 $IPF 140 allow all from any to any 80 in $IPF 141 allow all from any to any 80 out # NTP用 $IPF 150 allow tcp from any to any 123 in $IPF 151 allow tcp from any to any 123 out # HTTPS用 $IPF 160 allow all from any to any 443 in $IPF 161 allow all from any to any 443 out # 上記サービス以外へのTCP通信確立を拒否 $IPF 170 deny log tcp from any to any setup # 以下の2本は様子見用。いずれは削除の予定。 $IPF 65000 allow tcp from any to any 1024-65535 $IPF 65001 allow udp from any to any 1024-65535 # 他のサービスに関わる通信は拒否 $IPF 65535 deny all from any to any
~/.cshrc
tcsh環境設定。set pathより下はデフォルト状態のまま。
サーバ機につき日本語入力はsumibi.orgで間に合っているので、en_US.UTF-8にしてある。
setenv LANG en_US.UTF-8 setenv LC_ALL en_US.UTF-8 setenv EDITOR vim setenv VISUAL vim setenv PAGER less setenv BLOCKSIZE K alias ls ls -a alias vi vim alias rm rm -i alias cp cp -i # A righteous umask umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) if ($?prompt) then # An interactive shell -- set some stuff up set prompt = "%N@%m:%~ %# " set promptchars = "%#" set filec set history = 2000 set savehist = (2000 merge) set autolist = ambiguous # Use history to aid expansion set autoexpand set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif endif