当前位置:网站首页>iptables、firewalld的使用
iptables、firewalld的使用
2022-08-02 20:54:00 【m0_59138290】
iptables
- 搭建web服务,设置任何人能够通过80端口访问。
[[email protected] ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[[email protected] ~]# iptables -L --line-numbers
[[email protected] ~]# iptables -D INPUT 1
- 禁止所有人ssh远程登录该服务器
[[email protected] ~]# iptables -I INPUT -p tcp --dport 22 -j REJECT
删除设置的拒绝ssh连接:
[[email protected] Desktop]# iptables -D INPUT 1
- 禁止某个主机地址ssh远程登录该服务器,允许该主机访问服务器的web服务。服务器地址为172.24.8.128
拒绝172.24.8.129通过ssh远程连接服务器:
[[email protected] ~]# iptables -I INPUT -p tcp -s 172.24.8.129 --dport 22 -j REJECT
允许172.24.8.129访问服务器的web服务:
[[email protected] ~]# iptables -I INPUT -p tcp -s 172.24.8.129 --dport 80 -j ACCEPT
firewalld
- 禁止某个ip地址进行ssh访问
[[email protected] ~]# firewall-cmd --permanent --add-service=ssh
[[email protected] ~]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.1.1" service name="http,https" reject"
[[email protected] ~]# firewall-cmd --reload
配置端口转发(在172.24.8.0网段的主机访问该服务器的5423端口将被转发到80端口)此规则将本机80端口转发到192.168.1.1的8080端口上
[[email protected]1 ~]# firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“172.24.8.0/24” forward-port port=“5423” protocol=“tcp” to-port=“80”’
边栏推荐
猜你喜欢
随机推荐
ACE JET NPOI
人尽皆知的云原生,到底是大势所趋还是过度炒作?
PyRosetta 安装方法之Conda安装
Informatics Olympiad All-in-One (1257: Knight Moves)
Mysql用户管理
2018HBCPC个人题解
golang 刷leetcode:从栈中取出 K 个硬币的最大面值和
C primer plus学习笔记 —— 9、联合&枚举&typdef
Bena's life cycle
56.【全局变量和局部变量专题】
【3D视觉】深度摄像头与3D重建
PLC working principle animation
golang 刷leetcode:统计打字方案数
Bee 事务注解 @Tran 使用实例
Use the TCP protocol, we won't lost package?
js函数防抖和函数节流及其他使用场景
解道7-编程技术4
什么是幂等
传感器工作原理
二叉搜索树的实现









