之前有讲过公司新买的服务器使用的是CentOS 5.5,部署好Tomcat之后却发现输入114.80.*.*:8080(即ip:8080)却无法显示Tomcat默认的首页。因为以前部署在Win Server的VPS,Linux开发时也只用到localhost,所以就有点头大。
好吧,G一下网上有说是防火墙的问题,敲入
/etc/init.d/iptables stop
关闭之后再次查看114.80.*.*:8080(即ip:8080)发现果然成功。但是貌似安全隐患大大增加……使用
/etc/init.d/iptables status
查看防火墙信息,可以看到打开的端口。那么我们把需要使用的端口打开应该是一个比较可行的办法了,命令如下:
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT #8080为指定端口
/etc/rc.d/init.d/iptables save #将更改进行保存
/etc/init.d/iptables restart #重启防火墙以便改动生效,当然如果不觉得麻烦也可重启系统(命令:reboot)
当然了,还有另外直接在 /etc/sysconfig/iptables中增加一行:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
 
永久关闭防火墙
chkconfig –level 35 iptables off #此方法源自网络,未实验,安全考虑拒绝使用此方法

centos 端口开放及关闭 【转】的更多相关文章

  1. centos 端口开放及关闭

    之前有讲过公司新买的服务器使用的是CentOS 5.5,部署好Tomcat之后却发现输入114.80.*.*:8080(即ip:8080)却无法显示Tomcat默认的首页.因为以前部署在Win Ser ...

  2. CentOS/Linux开放某些端口

    CentOS/Linux开放某些端口 CentOS/Linux 装载系统的时候只开启了少数端口如22,80(有些连80都没有开放)等. 结果再装完Nginx+PHP+MySQL 后不能访问网站. 当然 ...

  3. CentOS 7 开放防火墙端口命令

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  4. CentOS 7 开放防火墙端口

    我:最近在使 CentOS 7时发现在本地不能访问linux上8080端口,以上是我的操作,修改后访问成功 CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现 ...

  5. CentOS 7 开放防火墙端口 命令(转载)

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  6. (原)centos 防火墙开放端口命令

    centos 防火墙默认是关闭非系统端口的,所以用到非系统端口首先开放,命令如下 firewall-cmd --zone=public --add-port=1935/tcp --permanent ...

  7. CentOS自带mysql配置(密码更改、端口开放访问、添加进系统启动项)

    前些天虚拟机安装好了CentOS6.1,但是自己想远程连接自带的mysql发现不知道如何改密码,于是谷歌一下,把结果记录下来,方便后期自己使用: 方法一: # /etc/init.d/mysql st ...

  8. CentOS 7 开放防火墙端口 命令

    iptables防火墙 1.基本操作 # 查看防火墙状态 service iptables status   # 停止防火墙 service iptables stop   # 启动防火墙 servi ...

  9. CentOs7 防火墙的开放与关闭及端口的设定

    1.查看firewall服务状态 systemctl status firewalld 2.查看firewall的状态 firewall-cmd --state 3.开启.重启.关闭.firewall ...

随机推荐

  1. JAVA按数字,字母排序,但不包括大小写和汉字排序

    public class ABC { public static void main(String[] args) { new ABC().sortStringArray(); } public vo ...

  2. images

  3. 生成器 Generators

    function* quips(name) { yield "你好 " + name + "!"; yield "希望你能喜欢这篇介绍ES6的译文&q ...

  4. csv,json格式数据的读写

    #!python3 # -*- coding:utf-8 -*- #CSV stands for "comma-separated values",and CSV files ar ...

  5. [Leetcode 122]买股票II Best Time to Buy and Sell Stock II

    [题目] Say you have an array for which the ith element is the price of a given stock on day i. Design ...

  6. 控制台程序读取WIKI形式的TXT文件并一表格的形式显示在Word中

    'Imports System.Collections.Generic 'Imports System.Text 'Imports System.IO 'Imports office = Micros ...

  7. node 慕课笔记

    global global.testVar2 = 200; 在别的文件中可以任意调用到 因为global是全局变量相当于js的window一样的

  8. Cracking The Coding Interview 1.6

    //原文: // // Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, w ...

  9. <context:annotation-config/>和<mvc:annotation-driven/>及解决No mapping found for HTTP request with URI [/role/getRole] in DispatcherServlet with name 'springmvc-config'

    1:什么时候使用<context:annotation-config> 当你使用@Autowired,@Required,@Resource,@PostConstruct,@PreDest ...

  10. python flask 小项目

    0 开始之前 网上看了很多教程,都不是很满意,因此自己写一个大型教程,从入门到做出一个比较完整的博客.此次教程不是直接把整个博客直接代码整理出来然后运行一遍就完事,我会从flask的各个模块讲起.所以 ...