2013/06/23

centos 6 設定 ssh iptables selinux

環境:CentOS6.4 ×86_64
SSH
sshのポート番号変更とPassword認証不可とRootlogin不可に設定
#vi /etc/ssh/sshd_configPort 22 -> Port 任意の番号(10022)
PasswordAuthentication yes -> no
PermitRootLogin no -> yes
#service sshd restart
authorized_keysを設定
$mkdir .ssh
$chmod 700 .ssh
$vi .ssh/authorized_keys

クライアントで作成したid_rsa.pubを転送して中身をコピペ
$chmod 600 .ssh/authorized_keys
 
iptables
iptablesを設定
#vi iptables-set.sh#!/bin/bash
# フィルタリングルールを消去する
/sbin/iptables -F
# デフォルトポリシーを設定(最初にすべてのポリシーをDROPに設定)
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT DROP
# ループバックを許可する
/sbin/iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
/sbin/iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
# プライベートアドレスが使われているパケットを破棄
/sbin/iptables -A INPUT -i eth0 -s 10.0.0.0/8 -j DROP
/sbin/iptables -A INPUT -i eth0 -d 10.0.0.0/8 -j DROP
/sbin/iptables -A INPUT -i eth0 -s 172.16.0.0/12 -j DROP
/sbin/iptables -A INPUT -i eth0 -d 172.16.0.0/12 -j DROP
# 基本サービスを許可, SSH
/sbin/iptables -A INPUT -p tcp -m state –state NEW -m tcp –dport 10022 -j ACCEPT
# すでにコネクションを確立しているものは許可
/sbin/iptables -A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
# Ping of Death対策
/sbin/iptables -A INPUT -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
# 外への接続は全て許可
/sbin/iptables -P OUTPUT ACCEPT
# 保存 + iptables再起動
/etc/init.d/iptables save
/etc/init.d/iptables restart
# 設定が適用されているか確認
/sbin/iptables -L
iptablesの確認
#iptables -L Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all — localhost localhost
DROP all — 10.0.0.0/8 anywhere
DROP all — anywhere 10.0.0.0/8
DROP all — 172.16.0.0/12 anywhere
DROP all — anywhere 172.16.0.0/12
ACCEPT tcp — anywhere anywhere state NEW tcp dpt:10022
ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp — anywhere anywhere icmp echo-request limit: avg 1/sec burst 5
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all — localhost localhost
iptablesのfilterテーブルは、
chainがINPUT,OUTPUT,FORWARDの3つあって
それぞれに全体のポリシー(ACCEPT/DROP)を指定して
必要があれば個別にACCEPT/DROPをする。 

selinux
一時設定(Enforcing:有効/Permissive:警告のみ/disabled:無効)
#getenforce
Enforcing
#setenforce 0
# getenforce

Permissive
設定
# vi /etc/selinux/config
SELINUX=disabled

0 件のコメント:

コメントを投稿

L2TP/IPSEC-VPN IX2025 リモートアクセス.

リモートアクセス VPN テスト シナリオ 想定1:インターネット VPN を使用したリモートアクセス VPN 想定2: VPN 構築後に iphone からインターネットに接続する 機器: NEC  IX2025(8.11.11) と iphone 目標1: LTE 通信の i...