CentOS 7 使用iptables 开放端口
2024-09-01 19:18:01
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service
2、安装iptables防火墙
yum install iptables-services -y
3.启动设置防火墙
# systemctl enable iptables
# systemctl start iptables
4.查看防火墙状态
systemctl status iptables
5编辑防火墙,增加端口
vi /etc/sysconfig/iptables #编辑防火墙配置文件
-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 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
:wq! #保存退出
3.重启配置,重启系统
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
//新建mysql用户并授权
grant all privileges on *.* to test@localhost identified by 'q123456';
最新文章
- iOS 视图:重绘与UIScrollView(内容根据iOS编程编写)
- Jquery基础知识
- 关于JSPatch热修复
- 全真模拟 (1) day1
- 利用zxing制作彩色,高容错,支持中文等UTF编码的QR二维码图片
- 【Android自学之旅】 Android开发环境的搭建
- Linux学习系列之Linux入门(二)Vim学习
- Android在onCreate()中获得控件尺寸
- linux下利用openssl来实现证书的颁发(详细步骤)
- js原生封装自定义滚动条
- JavaFx初探
- x240 uefi ubuntu 12.04.4
- hdu_5831_Rikka with Parenthesis II(模拟)
- 【转】ActiveMQ与虚拟通道
- win8 wifi开关显示关闭,且设置里面wifi开关显示灰色的解决办法
- 关于 Senparc.Weixin.Cache.Redis 引用的 StackExchange.Redis 版本不匹配的反馈测试
- [Swift]LeetCode109. 有序链表转换二叉搜索树 | Convert Sorted List to Binary Search Tree
- Vsphere 回收未消使用的磁盘空间
- LeetCode - Diameter of Binary Tree
- github 与gitlab之间的工程创建