• Centos5.8 iptables管理


    使用第三方提供的Centos5.8 vmx安装的虚拟机实例, 在安装Tomcat时发现启动后8080端口无法访问, 先检查是否selinux作了限制

    查看selinux状态: sestatus

    查看selinux对端口的限制情况: semanage port -l

    其中8080端口是否打开:

    semanage port -l|grep 8080

    排除了selinux的问题后, 发现是iptables引起. 查询发现, centos5.x里, 使用了一个 RH-Firewall-1-INPUT 的target, 所有INPUT和FORWARD都会target过去,

    -A INPUT -j RH-Firewall-1-INPUT -A FORWARD -j RH-Firewall-1-INPUT

    就是这个RH-Firewall-1-INPUT导致了8080端口无法访问.

    据说在Centos6.x 里面 RH-Firewall-1-INPUT 已经被废除. 因为是测试环境, 所以直接清空保存了:

    iptables -F iptables -X iptables -Z

    查看: iptables -L -n

    保存: service iptables save

    重启: service iptables start

    后查看是否生效

    RH官网上有详细解释: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_MRG/1.3/html/Messaging_Installation_Guide/sect-Messaging_Installation_Guide-Authentication_and_Authorization-FirewallConfiguration.html

    Update 20150711

    在Centos6.3里, 默认只打开了22端口, 其他的端口都需要到iptables里显式打开:

    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    在22端口的规则下面, 照抄即可, 例如开放8080端口的通信
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

  • 相关阅读:
    linux通过内容找文件的位置
    Mac通过端口查进程号
    执行brew update后显示Permission denied
    Linux通过进程ID查看文件路径
    Linux通过端口查进程号
    linux 如何查找命令的路径
    lua中冒号(:)与点号(.)的区别
    HTTP返回码301与302的区别
    vue使用animate.css类库实现动画
    vue过渡动画
  • 原文地址:https://www.cnblogs.com/milton/p/4215120.html
Copyright © 2020-2023  润新知