Linux 下开放指定端口

安装tomcat后,在客户端输入地址  http://localhost:8080/ ,发现默认端口8080不能访问。

 

  由于Linux防火墙默认是关闭8080端口。因此,若要能够访问8080端口,可以用两种方式,一个是关闭防火墙,另一个就是让防火墙开放8080端口。

 

  开放8080端口的解决步骤如下:

  1、修改/etc/sysconfig/iptables文件,增加如下一行:

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

       重启        iptables
       service iptables restart

  2、重启防火墙,这里有两种方式重启防火墙

 

  a) 重启后生效
  开启: chkconfig iptables on
  关闭: chkconfig iptables off

 

  b) 即时生效,重启后失效
  开启: service iptables start
  关闭: service iptables stop

 

  再次从客户端访问,成功!

posted @ 2014-09-23 22:34  小码哥、iByte  阅读(338)  评论(0编辑  收藏  举报