linux关于防火墙开放端口 -欧洲杯足彩官网

0顶
0踩

linux关于防火墙开放端口

2017-07-03 09:16 by 见习记者 星夜的遐想 评论(0) 有8128人浏览

一、查看防火墙开放了那些端口。

如下:22,3306已经对外开放了

[root@localhost tomcat7]# /etc/init.d/iptables status 
table: filter
chain input (policy accept)
num  target     prot opt source               destination         
1    accept     all  --  0.0.0.0/0            0.0.0.0/0           state related,established 
2    accept     icmp --  0.0.0.0/0            0.0.0.0/0           
3    accept     all  --  0.0.0.0/0            0.0.0.0/0           
4    accept     tcp  --  0.0.0.0/0            0.0.0.0/0           state new tcp dpt:22 
5    accept     tcp  --  0.0.0.0/0            0.0.0.0/0           state new tcp dpt:3306 
6    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 bin]# /etc/init.d/iptables status 
iptables: firewall is not running.

 

  

 

三、开放某个端口,如8080端口,

1、直接编辑/etc/sysconfig/iptables ,内容中新增一条

 -a input -m state --state new -m tcp -p tcp --dport 端口号 -j accept

注意位置需要放在-a input -j reject --reject-with icmp-host-prohibited前面。

 

[root@localhost /]# vi /etc/sysconfig/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 -m state --state new -m tcp -p tcp --dport 8080 -j accept
-a input -j reject --reject-with icmp-host-prohibited
-a forward -j reject --reject-with icmp-host-prohibited
commit

   2、重新启动防火墙服务 service iptables restart

    

[root@localhost bin]# service iptables restart
iptables: setting chains to policy accept: filter          [  ok  ]
iptables: flushing firewall rules:                         [  ok  ]
iptables: unloading modules:                               [  ok  ]
iptables: applying firewall rules:                         [  ok  ]

   

  四、直接关闭或打开防火墙(处于安全考虑不建议)

  1) 重启后生效 

   

开启: chkconfig iptables on 
关闭: chkconfig iptables off 

 

  2) 即时生效,重启后失效 

   

开启: service iptables start 
关闭: service iptables stop 

 

  附带,测试能不能访问某个端口是,可以用telnet命令,telnet host port 如:telent 192.168.101.11 8080

  如果telent命令不能识别,需要通过命令yum install telnet安装 (centos系统),windows 环境自行百度     下。

  

0
0
评论 共 0 条 请登录后发表评论

发表评论

您还没有登录,请您登录后再发表评论

相关推荐

  • 1.查看防火墙状态  查看防火墙状态 systemctl status firewalld  开启防火墙 systemctl start firewalld   关闭防火墙 systemctl stop firewalld  开启防火墙 service firewalld start   若遇到无法开启...

  • 运行完第二歩,表示添加端口已成功,可以用查看端口开放状态命令,查到是否开启成功。运行命令后,返回yes表示已打开,返回no表示未打开。若防火墙没打开,先打开防火墙。

  • linux系统防火墙开放端口

  • 移除指定端口:firewall-cmd --permanent --remove-port=3306/tcp。查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0。查看所有打开的端口: firewall-cmd --zone=public --list-ports。查看区域...

  • linux 防火墙

  • 查询已开放的端口(已开放的端口号集合):firewall-cmd --zone=public --list-ports。添加指定需要开放的端口:firewall-cmd --add-port=123/tcp --permanent。移除指定端口:firewall-cmd --permanent --remove-...

  • 查询已开放的端口(已开放的端口号集合):firewall-cmd --zone=public --list-ports。添加指定需要开放的端口:firewall-cmd --add-port=123/tcp --permanent。移除指定端口:firewall-cmd --permanent --remove-...

  • 防火墙: 1.firewalld的基本使用 启动: systemctl start firewalld 查状态: systemctl status firewalld 停止: systemctl disable firewalld 禁用: systemctl stop firewalld 在开机时启用一个服务: ...

  • 1.查看防火墙状态 查看防火墙状态 systemctl status firewalld 开启防火墙 systemctl start firewalld 关闭防火墙 systemctl stop firewalld 开启防火墙 service ...查询已开放的端口(已开放的端口号集合):f

  • linux系统下如何在防火墙开放指定端口/linux系统下的tomcat运行不成功怎么办

  • 在计算机网络中,端口是一种虚拟的通信机制,用于区分不同的网络应用程序和服务。每个网络应用程序都可以通过一个端口号来识别,从而在不同的网络连接中与其他应用程序进行区分。在 tcp/ip 协议中,每个端口都被分配...

  • linux防火墙添加开放端口。linux防火墙添加开放端口。--使新增的端口配置立即生效。

  • 很多时候我们需要通过外部来访问服务器,但是为了保证服务器的安全,不能完全关闭防火墙任由访问,所以我们只开放指定需要访问的端口 以开放8080端口为例 方法一(适用于centos7和低于7版本) 开启8080端口 /sbin...

  • 主要为大家详细介绍了linux下mysql开启远程访问权限,防火墙开放3306端口,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  • linux 系统的防火墙主要有两种,一种是 iptables,一种是 firewalld。iptables 是一个命令行工具,是 linux 系统内置的防火墙程序。它通过过滤网络数据包来保护服务器安全,并降低攻击风险。iptables 可以根据不同的...

  • 一、防火墙相关命令1、查看防火墙状态: systemctl status firewalld.service注:active是绿的running表示防火墙开启2、关闭防火墙 :systemctl stop firewalld.service3、开机禁用防火墙自启命令 :systemctl ...

  • vb语言vb光盘管理系统设计(源代码 系统)本资源系百度网盘分享地址

  • h型脚架疲劳测试机sw16可编辑_零件图_机械工程图_机械三维3d建模图打包下载.zip

  • 笔记.zip

  • python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。python社区提供了大量的第三方库,如numpy、pandas和requests,极大地丰富了python的应用领域,从数据科学到web开发。python库的丰富性是python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,matplotlib和seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。

global site tag (gtag.js) - google analytics
网站地图