LoginSignup
0
0

More than 1 year has passed since last update.

iptablesコマンドなどでlinuxサーバのセキュリティ対策をする 導入編

Posted at

linuxサーバのセキュリティ対策

サーバーでセキュリティ対策を色んな方法がありますが
一般的なiptablesを用いたセキュリティ対策を使ってみます。

インストール方法

まず、yumでiptablesをインストールします。

# yum install iptables-services

インストールされているかパッケージを確認します。

# yum list installed | grep iptables
# -> インストールされていれば以下のように帰ってきます。
 list installed | grep iptables
iptables.x86_64                              1.4.21-35.el7           @base

設定ファイルの場所は以下の場所にファイルが基本的に置いてあります。

/etc/sysconfig/iptables

iptablesの設定を確認します。

# iptables -L

基本的な設定方法

# iptables -I INPUT -s 攻撃IP -j DROP

上記コマンドで攻撃IPをブロック対象として設定します。

下記コマンドでiptablesの設定を設定ファイルに保存します。

# service iptabels save

設定を反映させるためにiptabelsを再起動します。

# service iptabels save
あるいは
# systemctl start iptables

設定の確認方法

# cat /etc/sysconfig/iptables

で設定ファイルに記載されているか確認します。

iptables -L

でiptablesが設定されているか確認します。

攻撃元の確認方法の一例

# lastb -20 -i 

サーバにログインしようとして失敗したIPやホスト名を表示するコマンドです。

# cat /var/log/messages

ログファイルを読み、不審なアクセスないか確認します。

ss -at

ネットワークのソケットの情報を出力して特定の送信元から多数のアクセスがないか確認します。

他にも色々なiptabelsで不正アクセスを防ぐ設定方法と不正アクセスの突き止め方があるので勉強していきたいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0