概要
ルータを設置します.ルータは取り替え可能なように ディスクレスクライアントとし,その他の作業をさせないようにします.
ハードウェア
あまりに遅くて計算機としては全然使い物にならないような, 余っているマザーボードを使った
- MotherBoard: Intel Desktop board D815EEA
- CPU: Intel Pentium III (Coppermine) 800MHz
- Memory: 512M(128+128+256) PC100 DIMM
- LAN: onboard e100 (not used)
r8169 (eth1) global 133.87.45.34
e1000 (eth0) local 10.0.1.0
システムのインストール
debian32の最小インストール スナップショット "zfspool/system/debian32@minimum" を使用する.
nfsサーバ(pirika)
- 既にシステムがあるのでコピーする
pirika# zfs clone zfspool/system/debian32@minimum zfspool/system/cerberus pirika# zfs set sharenfs=on zfspool/system/cerberus pirika# zfs set sharenfs="-maproot=0 10.0.1.0" zfspool/system/cerberus
- etc 以下にある以下のファイルを編集
- fstab, hosts, hostname, mailname, network/interfaces
- udev/rules.d/* を消去
- var/log 以下のファイルを空にして,*.1 や *.gz を消す
tftpサーバ(jupiter)
- /tftpboot 以下に cerberus ディレクトリを作り設定
jupiter# cd /tftpboot jupiter# mkdir cerberus jupiter# cd cerberus jupiter# scp pirika:/system/cerberus/boot/vmlinuz . jupiter# scp pirika:/system/cerberus/boot/initrd.img . jupiter# scp pirika:/system/cerberus/usr/lib/syslinux/pxelinux.0 . jupiter# mkdir pxelinux.cfg jupiter# cd pxelinux.cfg jupiter# vi 0A000100
- 0A000100 の中身は以下のようにする
default debian prompt 1 noescape 0 allowoptions 0 timeout 60 label debian kernel vmlinuz append root=/dev/nfs netboot=nfs initrd=initrd.img nfsroot=10.0.1.1:/system/cerberus ip=eth0 rw
dhcpサーバ(jupiter)
- /etc/dhcp/dhcpd.conf に以下を追加
host cerberus { hardware ethernet xx:xx:xx:xx:xx:xx; fixed-address 10.0.1.0; option root-path "10.0.1.1:/system/cerberus"; filename "/cerberus/pxelinux.0"; }
- xx:xx:xx:xx:xx:xx にはMACアドレスを調べて入れる
- ネットワーク起動してみれば dhcpサーバにログが残るので分かる
設定
biosの設定
- cerberus はオンボードLANを使用せず,PCIのLANのみ使用するため, オンボードのLANを無効にする.
- e1000からの起動を最優先に設定する
- キーボードやディスプレイが検出されないときに エラーとなって起動が中断する機能を無効化する
まずは,キーボードとディスプレイをつないだ状態のまま起動する
シリアル化
シリアル端末から操作できるように設定する
tftpサーバの設定
- /tftpboot/cerberus/pxelinux.cfg/0A000100 を編集
- 最初の行を serial 0 9600 に
- kernelオプションに console=ttyS0,9600n8 を追加
inittabの設定
- /etc/inittab に 以下の行を追加
s0:2345:respawn:/sbin/agetty -L -f /etc/issue 9600 ttyS0 vt100
ここでキーボードとディスプレイを外して再起動する
シリアル線を用意し,シリアルでの起動を確認する
sshd の設定
セキュリティー強化のためパスワードログインを禁止し, ssh鍵を必須にします
- /etc/ssh/sshd_config 編集
PermitRootLogin without-password PasswordAuthentication no
- sshホスト鍵の作り直し
# rm /etc/ssh/ssh_host_* # dpkg-reconfigure openssh-server
exim4 の設定
MTAとして元から入っているexim4を使います
- dpkg-reconfigureで設定する
# dpkg-reconfigure exim4-config
- 質問には 標準端末(ldap) と同じように答える
cron 定期レポートの設定
定期レポートスクリプトを送るように設定します
- 設定自体は 標準端末(cron) と同じです.
- 送信時刻を 4:30(毎日) と 5:00(毎週) に設定
ldap の設定
外部から入ることのできる唯一の端末なので, ホームディレクトリと認証情報を共有する
iptables の設定
NATルータとするためにiptablesを設定します
/etc/sysctl.confの設定
net.ipv4.tcp_syncookies=1 net.ipv4.ip_forward=1 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_filter = 1
/etc/network/interfaces の設定
auto lo iface lo inet loopback iface eth0 inet static address 10.0.1.0 netmask 255.255.0.0 network 10.0.0.0 broadcast 10.0.255.255 post-up iptables-restore < /etc/network/iptables auto eth0 iface eth1 inet static address 133.87.45.34 netmask 255.255.255.0 network 133.87.45.0 broadcast 133.87.45.255 gateway 133.87.45.1 auto eth1
iptables の作成
- iptables でテーブルを実際に作成する
- シェルスクリプトを作成
#!/bin/sh # flush rules iptables -F iptables -t filter -F iptables -t nat -F iptables -X # policy iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT # input filter (ssh only) iptables -N from_gaibu iptables -A from_gaibu -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A from_gaibu -p tcp -m state --state NEW --dport 22 -j ACCEPT iptables -A from_gaibu -p icmp -j ACCEPT # output filter (any) iptables -N to_gaibu iptables -A to_gaibu -d 10.0.0.0/8 -j DROP iptables -A to_gaibu -d 172.16.0.0/12 -j DROP iptables -A to_gaibu -d 192.168.0.0/16 -j DROP # forward filter (none) iptables -N forwarder iptables -A forwarder -m state --state ESTABLISHED,RELATED -j ACCEPT # input settings iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -i eth1 -j from_gaibu iptables -A INPUT -i eth0 -j ACCEPT # output settings iptables -A OUTPUT -o eth1 -j to_gaibu # forward settings iptables -A FORWARD -i eth1 -j forwarder iptables -A FORWARD -o eth1 -j to_gaibu iptables -A FORWARD -i lo -j ACCEPT iptables -A FORWARD -i eth0 -j ACCEPT # NAT settigs iptables -t nat -A POSTROUTING -o eth1 -s 127.0.0.1 -j MASQUERADE iptables -t nat -A POSTROUTING -o eth1 -s 10.0.0.0/16 -j MASQUERADE
- シェルスクリプトを作成
- iptables-save でダンプ
cerberus# sh iptables.sh cerbsrus# iptables-save > /etc/network/iptables
- nfsroot 環境では実行できないかもしれない
- iptables ファイルを適宜編集する
確認
- NAT内側から外のサーバにsshしてみる
- w コマンドや last コマンドで cerberus からの ログインになっていればOK
- ブラウザで適当なホームページを見てみる
- メールのクライアントを使ってみる