CentOS 7 iptables 설정

Linux 2016. 1. 15. 13:00

우선 방화벽을 중지한다.

[root@localhost log]# systemctl stop firewalld     

[root@localhost log]# systemctl mask firewalld       



iptables관련 패키지를 설치(업데이트)한다.

[root@localhost log]# yum install iptables-service    



부팅시 시작되도록 한다.

[root@localhost log]# systemctl enable iptables     



iptables 설정파일은 /etc/sysconfig/iptables 이다.


해당 파일을 편집한다.


1. 특정 IP 또는 IP블럭을 거부하고자 할 때,


-A INPUT -s 177.91.82.23 -j DROP

-A INPUT -s 177.91.82.0/24 -j DROP


와 같은 형태로 추가해 준다.



2. 특정 포는 특정 IP 또는 IP블럭에게만 허가하기


-A INPUT -s 192.168.0.0/24 -p tcp --dport 22 -j ACCEPT





iptables 상태확인


[root@localhost log]# systemctl status iptables

iptables.service - IPv4 firewall with iptables

   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)

   Active: active (exited) since 수 2016-01-13 11:31:40 KST; 1 day 23h ago

  Process: 31836 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)

  Process: 31903 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)

 Main PID: 31903 (code=exited, status=0/SUCCESS)

   CGroup: /system.slice/iptables.service


 1월 13 11:31:40 localhost.localdomain systemd[1]: Starting IPv4 firewall with iptables...

 1월 13 11:31:40 localhost.localdomain iptables.init[31903]: iptables: Applying firewall rules: [  OK  ]

 1월 13 11:31:40 localhost.localdomain systemd[1]: Started IPv4 firewall with iptables.



iptables 재시작


[root@localhost log]# systemctl restart iptables











'Linux' 카테고리의 다른 글

CentOS 7 아파치 2.4.6 한글깨짐 AddDefaultCharset  (0) 2016.01.15
CentOS 7 apache virtualhost  (2) 2016.01.15
CentOS 7 APM yum 설치 MariaDB  (11) 2016.01.15
CentOS 7 MySQL-5.7.10 설치 boost  (0) 2016.01.11
CentOS 7 network prefix  (0) 2015.12.04
블로그 이미지

엘로드넷

,