전체 페이지뷰

2016년 3월 16일 수요일

firewall port open in linux centos 6, 7

# su - root
cat /etc/*-release | uniq

CentOS Linux release 7.1.1503 (Core)
CentOS release 6.6 (Final)

if your os is centOS 7 then 

# cd /etc/firewalld/zones/
# ls
internal.xml  internal.xml.old  public.xml  public.xml.old
# vi internal.xml

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Internal</short>
  <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ipp-client"/>
  <service name="mdns"/>
  <service name="dhcpv6-client"/>
  <service name="samba-client"/>
  <service name="ssh"/>
  <port protocol="tcp" port="1521"/>
  <port protocol="tcp" port="8080"/>
  append port number
</zone>

# systemctl restart firewalld
# iptables-save

# Generated by iptables-save
.....
.....
-A IN_internal_allow -p tcp -m tcp --dport 1521 -m conntrack --ctstate NEW -j ACCEPT
-A IN_internal_allow -p tcp -m tcp --dport 8080 -m conntrack --ctstate NEW -j ACCEPT
COMMIT
# Completed on Tue Mar  8 17:00:04 2016

if your os is centOS 6 then

# vi /etc/sysconfig/iptables

append port number
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

# service iptables restart
OR
# /etc/init.d/iptables restart

댓글 없음:

댓글 쓰기