Getting started with iptables in Linux 리눅스에서 iptables와 함께 시작하기

by Sukrit Dhandhania on December 8, 2008 Sukrit Dhandhania 2008년 12월 8일에 의해

리눅스보안

Linux machines are known to be pretty secure. 리눅스 머신을 꽤 안전한 것으로 알려져있다. Studies have shown that Linux has been designed in a secure manner. 연구 리눅스 보안 방식으로 설계되었습니다 보여왔다. 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. 아직, 리눅스 설치와 함께 번들로 온 모든 보안 기능에도 불구하고, 당신을 올바르게 구성하는 그들이 당신을 위해 일할 수 있도록 이러한 기능이 필요합니다. I’ll guide you through the process of setting up of one of the tools that help secure your machine - the firewall. 하나의 도구가 도움이 귀하의 기계 - 안전한 방화벽의 설정의 과정을 통해 당신을 안내하겠습니다. 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. 난 당신이 서버에 레드햇 엔터 프라이즈 리눅스 4 또는 유사한 실행을 사용하는 가정입니다. However, most of the steps should work fine on other Linux distributions as well. 그러나 다른 리눅스 배포판에 좋을뿐 아니라 대부분의 단계. In this article we will setup a firewall on a Linux server running the Apache Web Server, FTP, and SSH. 리눅스 서버는 아파치 웹 서버, 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. 아파치 웹 서버는 기본적으로 포트 80에서 실행됩니다. Apache is going to server all our web content on this port, therefore we need to keep this port open on the firewall. 아파치 서버는이 포트에, 그러므로 우리는이 포트가 방화벽에서 열려 우리의 모든 웹 콘텐츠에 갈 두실 필요가있습니다. 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: 루트 사용자로이 명령을 실행합니다 :

# rpm -qa | grep iptables # rpm에서 - 품질 보증 | 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 iptables # 얌 iptables 설치

# /etc/init.d/iptables start #에서는 / etc / init.d / iptables 시작

To check what kind of configuration iptables is currently running with: iptables 구성을 확인하려면 어떤 종류의 현재 실행중인 :

# iptables –list # iptables - 목록
Chain INPUT (policy ACCEPT) 체인 입력 (정책에 동의)
target prot opt source destination 목표를 보호해주는 원본을 대상 제외

Chain FORWARD (policy ACCEPT) 체인 포워드 (정책에 동의)
target prot opt source destination 목표를 보호해주는 원본을 대상 제외

Chain OUTPUT (policy ACCEPT) 체인 출력 (정책에 동의)
target prot opt source destination 목표를 보호해주는 원본을 대상 제외

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를 위해 귀하의 웹 서버, 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 # 플러시 (-여)는 모든 구체적인 규칙
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 - eth0 - p를 입력 - i 명령은 TCP - 어떠한 $ s에 - D는 $ 어떠한 - 목적지 - 포트 $ 포트 -가 SYN - j를 수락
iptables -A INPUT -i eth1 -p tcp -s $ANY -d $ANY –destination-port $port –syn -j ACCEPT iptables - eth1 - p를 입력 - i 명령은 TCP - 어떠한 $ s에 - D는 $ 어떠한 - 목적지 - 포트 $ 포트 -가 SYN - j를 수락
done 했다

iptables -A INPUT -i eth1 -p icmp -s $ANY -d $ANY -j ACCEPT iptables - eth1 - p를 입력 - i 명령은 ICMP - 어떠한 - j를 인정하는 모든 - D는 $ $ s에

#Allow any related/established connections 관련 허용 # / 설립 연결
iptables -A INPUT -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables - 입력 - i을 eth0 - 난 상태 - 상태, 관련 - j를 수락 개설
iptables -A INPUT -i eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables - eth1는 - m - i 명령 입력 상태 - 상태, 관련 - j를 수락 개설

#Kill everything else 다른 모든 것들을 죽여 #
iptables -A INPUT -i eth0 -j DROP iptables - 입력 - i을 eth0 - j를 받겠지
iptables -A INPUT -i eth1 -j DROP iptables - eth1 - j를 입력 - i 명령을 받겠지?

#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.sh # chmod를 + x는 iptable - firewall.sh

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

Now check your firewall rules: 이제 귀하의 방화벽 규칙을 확인 :

# iptables –list # iptables - 목록

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 설치 방법 방화범 - 리눅스 방화벽을 사용하기 쉬운 - 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 어떻게 리눅스 커맨드 라인에서 이메일을 보낼 수
  • How to install, setup and use Google Desktop Search in Ubuntu 방법, 설치 프로그램을 설치하고 우분투에서 Google 데스크톱 검색 사용
  • How to install Windows programs in Linux using Wine 리눅스에서 와인을 사용하여 Windows 프로그램을 설치하는 방법
  • How to play .rmvb files in Ubuntu 플레이 방법. rmvb 파일 우분투는에
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! 귀하의 이메일받은 편지로 매일 - 자유에 대한 간단한 도움말 튜토리얼이 하나처럼 들어가! 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 태그와 특성 : title="">은 <a href="" 사용할 수있습니다 <abbr title=""> <acronym title="">의 <b> <blockquote cite=""> <cite>의 <code> <del datetime="">의 <em>가 <i> <q cite=""> <strike>의 <strong>