Getting started with iptables in Linux Linuxでiptablesのスタートガイド

by Sukrit Dhandhania on December 8, 2008 Sukrit Dhandhania 2008年12月 8日にで

リナックスセキュリティ

Linux machines are known to be pretty secure. Linuxマシンはかなり安全に行われることが知られています。 Studies have shown that Linux has been designed in a secure manner.研究は、 Linuxは、安全な方法で設計されていますを示している。 Yet, despite all the security features that come bundled with a Linux installation, you need to configure these features correctly to make them work for you.しかし、それはLinuxのインストールにバンドルされるすべてのセキュリティ機能にもかかわらず、それらを構成するが正しく動作させるためにこれらの機能が必要です。 I’ll guide you through the process of setting up of one of the tools that help secure your machine - the firewall.私は1つのツールを支援するお使いのマシン-を確保するのは、ファイアウォールの設定の手順を案内させていただきます。 We will use the iptables firewall for this exercise.私たちはこの演習のためのiptablesのファイアウォールを使用します。 I am assuming that you are using a server running Red Hat Enterprise Linux 4 or similar.私の場合は、サーバーのRed Hat Enterprise Linux 4または類似を実行して使用していると仮定しています。 However, most of the steps should work fine on other Linux distributions as well.しかし、他のLinuxディストリビューションでもうまくいくでしょうの手順のほとんど。 In this article we will setup a firewall on a Linux server running the Apache Web Server, FTP, and SSH.は、 Linuxサーバーは、 Apache Webサーバ、 FTP 、およびSSHをするセットアップを実行している私たちは、ファイアウォール、この資料では。

Let us first see what ports these applications use and which of them need to have a port open on the firewall.私たち最初のポートを使用し、これらのアプリケーションをどう見てみましょうはそれらのポートは、ファイアウォール上で開いている必要があります。

The Apache web server runs on port 80 by default.は、 Apache Webサーバはデフォルトではポート80上で動作します。 Apache is going to server all our web content on this port, therefore we need to keep this port open on the firewall. Apacheサーバには、このポート上で、そのため私たちは、このポートは、ファイアウォール上でオープンする必要があるすべてのWebコンテンツを進んでいる。 The SSH service runs on port 22.サービスは、 SSHのポート22上で動作します。 We need to be able to remotely connect to our server to work, so we keep it open.私たちは当社のサーバーにリモート接続できるように仕事をしなければならないため、それを開けておく必要があります。 FTP runs on port 21 and it too needs the port to be open to communication. FTPのポート21上で動作しても通信に開放するポートを必要とします。

Next, make sure you have iptables installed.次に、 iptablesのインストールされていることを確認します。 Run this command as the root user:このコマンドはrootユーザーとして実行する:

# rpm -qa | grep iptablesrpmを、品質保証| grepがiptablesの

If you have iptables installed the system should give you the version of iptables you have installed. iptablesの場合はインストールされているのは、 iptablesのバージョンを与える必要があるシステムがインストールされている。 In case you don’t you can try something like the following to get it and start it:場合、それを取得し、それを起動は、以下のようなものにしてみてくださいしないでください:

# yum install iptablesyumのiptablesのインストール

# /etc/init.d/iptables startは/ etc / init.d / iptablesの起動

To check what kind of configuration iptables is currently running with: iptablesの設定の種類を確認するには、現在で実行されています:

# iptables –listiptablesのリスト
Chain INPUT (policy ACCEPT)チェーン入力(政策を受け入れます)
target prot opt source destinationターゲットprotのソース先の選択

Chain FORWARD (policy ACCEPT)チェーン前方(政策を受け入れます)
target prot opt source destinationターゲットprotのソース先の選択

Chain OUTPUT (policy ACCEPT)チェーン出力(政策を受け入れます)
target prot opt source destinationターゲットprotのソース先の選択

This command will list out all the firewall rules that have been set currently.このコマンドは、現在設定されているすべてのファイアウォールのルールを一覧表示されます。 I will proceed with the assumption that you do not have any firewall rules in your iptables configuration.私は、仮定の場合、 iptablesの設定ではファイアウォールのルールを持っていないと進みます。 Let’s now configure the firewall to allow open communication on the ports 80 for your web server, 22 for SSH, and port 21 for FTP.レッツする構成は、ファイアウォール、 SSHのは、 Webサーバー、 22用のポート80にオープンなコミュニケーションを許可するとFTPのポート21 。 We’ll also make sure that we block communication to any port other than specified.また、私たちの任意のポートを指定以外の通信をブロックしておいてくださいよ。

Here’sa firewall script configuration script.スクリプトを以下にファイアウォールの設定スクリプトを実行します。 Create a new file and call it iptable-firewall.sh .新しいファイルを作成し、そこiptable - firewall.shを呼び出します Copy the following text into it:その中に以下のテキストをコピー:

#!/bin/sh # ! / bin / shに

ANY=”0/0″いかなる= " 0 / 0 "
OPEN_PORTS=”21 22 80″ OPEN_PORTS = " 21 22 80 "

iptables -P INPUT ACCEPT iptablesの- pの入力同意
iptables -P FORWARD ACCEPT iptablesの- pの前方に同意する
iptables -P OUTPUT ACCEPT iptablesの- pの出力同意

# Flush (-F) all specific rules #フラッシュ( - F )のすべての固有のルール
iptables -F INPUT iptablesの- F入力
iptables -F FORWARD iptablesの- Fを転送
iptables -F OUTPUT iptablesの- Fを出力

for port in $OPEN_PORTS OPEN_PORTSポート$で
doする
iptables -A INPUT -i eth0 -p tcp -s $ANY -d $ANY –destination-port $port –syn -j ACCEPT iptablesの- A入力- iを任意のeth0 - pがtcp - dの$ $ sのすべての宛先ポート$ポート同時に、 - jを承認
iptables -A INPUT -i eth1 -p tcp -s $ANY -d $ANY –destination-port $port –syn -j ACCEPT iptablesの- A入力- iをeth1 - pがtcp - sの- dのあらゆる$ $任意の宛先ポート$ポート同時に、 - jを承認
done完了した

iptables -A INPUT -i eth1 -p icmp -s $ANY -d $ANY -j ACCEPT iptablesの- A入力- iをeth1 - pの任意のICMP - jに同意あらゆる- dの$ $秒

#Allow any related/established connectionsすべての関連する許可# /設置接続
iptables -A INPUT -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT iptablesの- eth0のは- m - iを入力状態の状態、関連- jに同意ESTABLISHED
iptables -A INPUT -i eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT iptablesの- A入力- iをeth1は- mの状態の状態、関連- jに同意ESTABLISHED

#Kill everything elseすべてを他の人を殺し#
iptables -A INPUT -i eth0 -j DROP iptablesの- A入力- iをのeth0 - jをにDROP
iptables -A INPUT -i eth1 -j DROP iptablesの- A入力- iをeth1 - jをにDROP

#write for bootブートを書く#
iptables-save > /etc/sysconfig/iptables iptablesの保存>は/ etc / sysconfig / iptablesの

Now save the above file, grant it executable permissions and then run it:現在、上記のファイルは、実行可能ファイルのアクセス許可を付与し、そしてそれを実行保存されたもの:

# chmod +x iptable-firewall.shchmod + xはiptable - firewall.sh

# ./iptable-firewall.sh。 / iptable - firewall.sh

Now check your firewall rules:現在使用してファイアウォールのルールをチェック:

# iptables –listiptablesのリスト

All your firewall rules should now be set.すべてのファイアウォールルールを設定する必要があります。 Your server is now secure.お客様のサーバーのセキュリティを強化するされています。 To make any modification or additions to this set of rules, edit the line where the OPEN_PORTS parameter is defined and add or remove ports form the list. 、行の編集にあらゆる変更やルールの設定を追加するには、 OPEN_PORTS定義されているパラメータを追加またはポートのリストフォームを削除します。 Remember to run the script again after making any changes to it.もう一度変更した後に任意のスクリプトを実行してください。

If all of this command line stuff has you a bit leery, see the tutorialこのコマンドラインの場合、すべてのものの場合はちょっと怖い、チュートリアルを参照してください How to setup Firestarter - an easy to use Linux Firewall炎の少女チャーリーのセットアップ方法について-L inuxのファイアウォールの使用方法は簡単 - which has an easy to use graphical interface. -これは、グラフィカルインタフェースを使用するように簡単にしている。

Related Posts: 関連記事:
  • How to set up Evolution for emailメールをどのように進化を設定する
  • How to send email from the Linux command line方法は、 Linuxのコマンドラインから電子メールを送信する
  • How to install, setup and use Google Desktop Search in Ubuntu方法については、セットアップをインストールするとUbuntuにGoogleデスクトップ検索を使用する
  • How to install Windows programs in Linux using WineどのようにLinuxにワインを使用してWindowsプログラムをインストールするには
  • How to play .rmvb files in Ubuntuどのように再生します。 rmvbファイルのUbuntuで
  • Get Simple Help tutorials just like this one in your email inbox every day - for free!お客様のメールの受信ボックスに毎日-無料で、この1つだけのような簡単なヘルプのチュートリアルを入手! Just enter your email address below:すぐ下にあなたのメールアドレスを入力してください:

    You can always opt out of this email subscription at any time.いつでも、いつでも、このメール購読のオプトアウトすることができます。


    Bookmark and Share ブックマークして共有する

    { 0 comments… 0コメント... add one now今すぐ追加 }

    Leave a Commentコメントを残しなさい

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> これらのHTMLタグ属性:の<a href=""使用することができますtitle=""> <abbr title=""> <acronym title=""> <b>ダウンロード<blockquote cite=""> <cite>の<code> <del datetime="">の<em> <i> <q cite=""> <strike> <strong>