Home > Operation and Maintenance > Linux Operation and Maintenance > How to add iptables firewall rules in linux

How to add iptables firewall rules in linux

王林
Release: 2023-05-24 18:34:06
forward
2050 people have browsed it

iptables设置

 *filter
:input drop [0:0]
:forward accept [0:0]
:output accept [49061:9992130]
-a input -i lo -j accept   不开启会有很多服务无法使用,开启回环地址
-a input -p icmp -j accept   允许icmp包通过,也就是允许别人ping自己
-a input -m state --state related,established -j accept
-a input -p tcp -m tcp --dport 21 -j accept
-a input -p tcp -m tcp --dport 25 -j accept
-a input -p tcp -m tcp --dport 80 -j accept
-a input -p tcp -m tcp --dport 110 -j accept
-a input -p tcp -m tcp --dport 8080 -j accept
-a input -p tcp -m tcp --dport 10337 -j accept 这是我自己的ssh连接端口
 -a input -j reject --reject-with icmp-host-prohibited
commit
Copy after login

注释:使用的时候要把规则后的中文注释去掉,上面也可以写成多端口方式

-a input -p tcp -m multiport --dports 21,25,80,110,3306,8080,10337 -j accept
Copy after login

Linux有哪些版本

Linux的版本有:Deepin、UbuntuKylin、Manjaro、LinuxMint、Ubuntu等版本。其中Deepin是国内发展最好的Linux发行版之一;UbuntuKylin是基于Ubuntu的衍生发行版;Manjaro是基于Arch的Linux发行版;LinuxMint默认的Cinnamon桌面类似Windows XP简单易用;Ubuntu则是以桌面应用为主的Linux操作系统。

The above is the detailed content of How to add iptables firewall rules in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template