• Linux上防火墙开放对应的端口


    在Linux上防火墙开放对应的端口的命令如下:

    方式一:

    [root@localhost sbin]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT   
    [root@localhost sbin]# 
    [root@localhost sbin]# /etc/rc.d/init.d/iptables save
    iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
    [root@localhost sbin]# 
    [root@localhost sbin]# /etc/rc.d/init.d/iptables restart
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    iptables: Applying firewall rules:                         [  OK  ]
    [root@localhost sbin]# 
    [root@localhost sbin]# /etc/rc.d/init.d/iptables status
    Table: filter
    Chain INPUT (policy ACCEPT)
    num  target     prot opt source               destination         
    1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80 
    2    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
    3    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
    4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
    5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
    6    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8080 
    7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8099 
    8    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:50031 
    9    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 
    
    Chain FORWARD (policy ACCEPT)
    num  target     prot opt source               destination         
    1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 
    
    Chain OUTPUT (policy ACCEPT)
    num  target     prot opt source               destination         
    
    [root@localhost sbin]# 

    命令介绍如下:

    /sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT #开启8011端口 
    /etc/rc.d/init.d/iptables save #保存配置 
    /etc/rc.d/init.d/iptables restart #重启服务 
    查看端口是否已经开放
    /etc/init.d/iptables status 
     
    #######################################################

    其他方式:

    查看防火墙的状态:
    /etc/init.d/iptables status
     

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

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

    需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。 

    在开启了防火墙时,做如下设置,开启相关端口, 
    修改/etc/sysconfig/iptables 文件,添加以下内容: 
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

     
     
    这里应该也可以不重启计算机:
    #/etc/init.d/iptables restart
    关闭防火墙服务即可:
    查看防火墙信息:
    #/etc/init.d/iptables status
    关闭防火墙服务:
    #/etc/init.d/iptables stop
     
    -----简单的修改,在开启防火墙的情况下。放开对应端口,见下面红色。
    # Generated by iptables-save v1.4.7 on Mon Dec 26 16:43:03 2016
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [3:420]
    -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
    -A INPUT -p tcp -m tcp --dport 8999 -j ACCEPT
    -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
    -A INPUT -p tcp -m tcp --dport 8005 -j ACCEPT
    COMMIT
    # Completed on Mon Dec 26 16:43:03 2016
     
    一、Linux下开启/关闭防火墙命令
    1、永久性生效,重启后不会复原。
    开启: chkconfig iptables on
    关闭: chkconfig iptables off
    2、 即时生效,重启后复原
    开启: service iptables start
    关闭: service iptables stop
    需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。
    在当开启了防火墙时,做如下设置,开启相关端口,
    修改/etc/sysconfig/iptables 文件,添加以下内容:
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    二、UBuntu关闭防火墙
    iptables -A INPUT -i ! PPP0 -j ACCEPT
    三、CentOS Linux 防火墙配置及关闭
    执行”setup”命令启动文字模式配置实用程序,在”选择一种工具”中选择”防火墙配置”,然后选择”运行工具”按钮,出现防火墙配置界面,将”安全级别”设为”禁用”,然后选择”确定”即可.
    或者用命令:
    #/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
    #/sbin/iptables -I INPUT -p tcp –dport 22 -j ACCEPT
    #/etc/rc.d/init.d/iptables save
    这样重启计算机后,防火墙默认已经开放了80和22端口
    这里应该也可以不重启计算机:
    #/etc/init.d/iptables restart
    关闭防火墙服务即可:
    查看防火墙信息:
    #/etc/init.d/iptables status
    关闭防火墙服务:
    #/etc/init.d/iptables stop
     
  • 相关阅读:
    spring-pool.xml
    spring-jmx.xml
    spring-common.xml
    applicationContext.xml
    spring-webservice.xml
    webservice统一认证
    jdbc.properties
    oracle,mysql分页
    springmvc-servlet.xml
    四、用“”或构造函数创建Java的String区别
  • 原文地址:https://www.cnblogs.com/alsodzy/p/8522867.html
Copyright © 2020-2023  润新知