centos7 firewall指定IP与端口、端段访问(常用)
https://blog.csdn.net/yipianfuyunsm/article/details/99998332
https://www.cnblogs.com/co10rway/p/8268735.html
1、启动防火墙
systemctl start firewalld.service
2、指定IP与端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="5432" accept"
3、重新载入,使配置生效
systemctl restart firewalld.service
4、查看配置结果
firewall-cmd --list-all
5、删除规则
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept"
防火墙的FTP策略配置
放行20、21端口还是不能连接FTP,因为在PASV模式下,建立数据传输会随机开放端口,这个端口显然是没有处于firewall的允许策略之下的,因为需要修改配置文件,指定端口范围。
1 vi /etc/vsftpd/vsftpd.conf
在最后加入以下内容,端口尽量选择高范围,提高安全性
1 pasv_enable=YES #开启被动模式
2 pasv_min_port=30000 #随机最小端口
3 pasv_max_port=31000 #随机最大端口
然后对指定的IP开放指定的端口段
1 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="30000-31000" accept"
然后重启ftp、firewall,即可正常连接
centos7.3 firewalld防火墙指定IP策略--------龙胆苏打
firewall-cmd的命令行客户端支持和这个守护进程通信以永久修改防火墙规则
常用命令
firewall-cmd #防火墙的命令行
--permanent #永久
--remove #移除
--add #添加
--list-all #查询所有
1
2
3
4
5
查看配置结果
firewall-cmd --list-all
1
显示如下
public (default)
interfaces:
sources:
services: dhcpv6-client ftp ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="192.168.1.1" port port="2000-30000" protocol="tcp" accept
rule family="ipv4" source address="192.168.1.19" " accept
1
2
3
4
5
6
7
8
9
10
11
#删除策略指定ip策略
语法
firewall-cmd --permanent --remove-rich-rule="《删除的信息》"
1
例子1
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.1.1" port port="2000-30000" protocol="tcp" accept"
1
例子2
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.1.19" " accept"
1
重新加载防火墙
firewall-cmd --reload #在不改变状态的条件下重新加载防火墙
添加策略指定ip策略
语法
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="终端ip" accept"
1
例子1
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.1.1" accept"
1
例子2
firewall-cmd --permanent --permanent --remove-rich-rule family="ipv4" source address="192.168.1.1" port port="1521" protocol="tcp" accept
1
开启防火墙
systemctl restart firewalld
或者重新加载防火墙
firewall-cmd --reload #在不改变状态的条件下重新加载防火墙与 systemctl restart firewalld类似的效果
————————————————
版权声明:本文为CSDN博主「龙胆苏打」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/yipianfuyunsm/article/details/99998332
centos7 firewall指定IP与端口、端段访问(常用)的更多相关文章
- centos7 firewall指定IP与端口访问(常用)
1.启动防火墙 systemctl start firewalld.service 2.指定IP与端口 firewall-cmd --permanent --add-rich-rule="r ...
- pycharm中指定ip和端口
pycharm中指定ip和端口 环境: 系统:win7 本机ip:192.168.0.100 1.建立工程请参照:https://www.cnblogs.com/effortsing/p/103945 ...
- MySQL指定ip和端口连接数据库,并修改数据库密码
一.指定ip和端口连接数据库 命令 mysql -u root -h (ip) -P (端口)-p 假设ip是:127.0.0.1:端口是:13326,连接的命令: mysql -u root -h ...
- python - socket - client端指定ip和端口
问题描述: 在设备中有3个NI, ip分别为192.168.1.5/6/7.其中本端192.168.1.6同对端192.168.1.10建立了一个tunnel. 我希望测试tunnel连通性, 对端起 ...
- 运行Django项目指定IP和端口
默认IP和端口 python manage.py runserver 指定端口: python manage.py runserver 192.168.12.12:8080 此时会报错,我们需要修改配 ...
- Linux CentOS7 开启80,443端口外网访问权限
一.查看系统防火墙状态(如果返回 running 代表防火墙启动正常) firewall-cmd --state 二.开启端口外网访问 1.添加端口 返回 success 代表成功(--permane ...
- 配置linux 防火墙,只有固定IP和端口才能能访问完美解决
//添加开放的端口和固定ip vi /etc/sysconfig/iptables [root@root220156 /]# echo "unset MAILCHECK"> ...
- Centos7(Firewall)防火墙开启常见端口命令
使用云服务器的,一定要注意开启安全组配置的响应端口 Centos7默认安装了firewalld,如果没有安装的话,则需要YUM命令安装:firewalld真的用不习惯,与之前的iptable防火墙区别 ...
- 扫描指定ip的端口(C#)
class PingExam { public static void Main() { Ping ping = new Ping(); string ip = "192.168.1.43& ...
随机推荐
- Google Python Style Guide
https://google.github.io/styleguide/pyguide.html
- Kotlin入门-文件读写操作
转 https://blog.csdn.net/aqi00/article/details/83241762 Java的文件处理用到了io库java.io,该库虽然功能强大,但是与文件内容的交互还得通 ...
- VBA 格式化excel数据表 (数据分列)
Sub ImportData() ' ' Copy Data from one workbook to the Current Workbook ' Place the macro file in t ...
- 安装mysql问题解决
[root@apollo init.d]# /etc/init.d/mysqld startmy_print_defaults: Can't read dir of '/etc/my.cnf.' (E ...
- 阶段5 3.微服务项目【学成在线】_day03 CMS页面管理开发_07-新增页面-前端-页面完善
在新增页面加返回按钮 <el-button type="primary" @click="go_back" >返回</el-button> ...
- SpringBoot学习之一 Unable to find a single main class from the following candidates
在启动SpringBoot项目是报错 Unable to find a single main class from the following candidates [boot.myboot.Sam ...
- 使用super函数----增量重写普通方法和构造方法
使用super函数----增量重写普通方法和构造方法 在子类中如果重写了超类的方法,通常需要在子类方法中调用超类的同名方法,也就是说,重写超类的方法,实际上应该是一种增量的重写方式,子类方法会在超类的 ...
- Kuhn-Munkras算法解决二分图最优权值匹配
在看这篇博文之前建议看一下上一篇匈牙利法解决二分图最大匹配问题: https://www.cnblogs.com/fangxiaoqi/p/10808729.html 这篇博文参考自:https:// ...
- Vue触发隐藏input file的方法
1.使用input透明覆盖法 将input的z-index设置为1以上的数字并覆盖到需点击的内容上,将input的样式opacity设置为0(即为透明度为0),这样通过绑定在input上的change ...
- 【VS开发】VS2010 MFC中控件、对话框等背景颜色动态修改的方法
[VS开发]VS2010 MFC中控件.对话框等背景颜色动态修改的方法 标签(空格分隔):[VS开发] 声明:引用请注明出处http://blog.csdn.net/lg1259156776/ 说明: ...