2012年12月24日月曜日

お名前.com VPSにSL6.3をインストールした時のメモ

お名前.comのVPSサーバーにSL6をインストールした時のメモ。
cat /etc/redhat-release
Scientific Linux release 6.3 (Carbon)

ID関連

一般ユーザーを作って、sshを使ったrootログインを制限して、suできるユーザーを限定する。
useradd hoge
passwd hoge
usermod -G wheel hoge
vi /etc/ssh/sshd_config
Port 2022
Protocol 2
SyslogFacility AUTHPRIV
PermitRootLogin no
PasswordAuthentication yes
PermitEmptyPasswords no
ChallengeResponseAuthentication no
UsePAM yes
Subsystem       sftp    /usr/libexec/openssh/sftp-server
service sshd restart
vi /etc/pam.d/su
#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth           sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
auth            required        pam_wheel.so use_uid
auth            include         system-auth
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password        include         system-auth
session         include         system-auth
session         optional        pam_xauth.so
ついでにロケールを変更。
vi /etc/sysconfig/i18n
LANG="ja_JP.UTF-8"
SYSFONT="latarcyrheb-sun16"

IPv6関連

IPv6が有効になっているかを確認。
ifconfig -a
eth0      Link encap:Ethernet  HWaddr 52:54:01:00:62:10  
          inet addr:49.212.122.248  Bcast:49.212.123.255  Mask:255.255.254.0
          inet6 addr: fe80::5054:1ff:fe00:6210/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
IPv6を無効にする。
echo 'options ipv6 disable=1' >/etc/modprobe.d/disable-ipv6.conf
chkconfig ip6tables off
reboot

APIPA関連

APIPAが有効になっているかを確認する。
netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
49.212.122.0    0.0.0.0         255.255.254.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
0.0.0.0         49.212.122.1    0.0.0.0         UG        0 0          0 eth0
netowkを編集して無効にする。
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=v103-3-18-170.myvps.jp
GATEWAY=49.212.122.1
NOZEROCONF=yes
service network restart

yumリポジトリ関連

yumのプラグインを追加。
yum install yum-plugin-fastestmirror yum-plugin-priorities
sl.repoとsl-other.repoのプライオリティを1に設定し最優先にする。
cd /etc/yum.repos.d
vi sl.repo
それぞれのセクションの最後に以下の行を追加
priority=1
EPELをリポジトリに追加する。
yum install epel-release
IUS Yumリポジトリを追加する
wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/ius-release-1.0-10.ius.el6.noarch.rpm
rpm -Uvh ius-release-1.0-8.ius.el6.noarch.rpm
RPMforgeを追加する。
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
全てのパッケージをアップデートしておきます。
yum update

iptables

iptablesを一括設定するファイルを作成しておきます。 ここでは、sshd, http, smtpを開けておきます。
#!/bin/sh
/sbin/iptables -F
/sbin/iptables -X

/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD DROP

/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT

/sbin/iptables -A INPUT -s 10.0.0.0/8 -j DROP
/sbin/iptables -A INPUT -s 172.16.0.0/12 -j DROP
/sbin/iptables -A INPUT -s 192.168.0.0/16 -j DROP

/sbin/iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 2022 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 25 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT

/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

/etc/rc.d/init.d/iptables save

0 件のコメント:

コメントを投稿