当前位置:网站首页>On iptables
On iptables
2022-04-23 18:32:00 【Drunken Xiaobai】
One 、 Concept
iptables yes Linux Under the powerful firewall tools , Because it is integrated in Linux kernel , So it's very efficient .
Two 、 classification
Classify according to the operation category of the data packet ,iptables Can be divided into 4 Tables , According to different Hook Points can be divided into 5 A chain .
among 4 Two tables are filter surface ( For general filtering )、nat surface ( Address or port mapping )、mangle surface ( Modifications to specific packets )、raw surface , The most commonly used one is filter surface ;
5 The two chains are PREROUTING chain ( Before the packet enters the routing decision )、INPUT( Routing decisions for native packets )、FORWARD( Routing decisions are not native packets )、OUTPUT( Outgoing packets generated by the machine )、POSTROUTING( Packet before sending to network card ), The most common is INPUT、OUTPUT chain .
3、 ... and 、 Work strategy
The first is to accept only allowed data , This kind of policy is generally to set the default policy of the firewall to reject all packets ( That is to say, the data packets on the network card are rejected ), Then release the specific access ; The second is to prevent only disallowed data access requests , This policy is generally to set the default policy of the firewall to allow all packets , Deny only known illegal access to data . In terms of safety effect , The former firewall strategy performs better /
Four 、 Configuration rules
#cat /etc/sysconfig/iptables
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT # Allow established and related packets to enter / Represents the host that has established a connection with this machine , Still connected
-A INPUT -p icmp -j ACCEPT # stay INPUT Add allow... To the rule chain ICMP Flow in
-A INPUT -i lo -j ACCEPT
-A INPUT -i bond0 -s x.x.x.x -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT # Allow fixed IP can SSH Go to the server
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT # allow access to 80 port
-A INPUT -s x.x.x.x -p tcp -m multiport --dports 80,10011,3000,6379,9307 -j ACCEPT # Allow fixed IP Can access some ports of the server
-A INPUT -p tcp --dport 3000 -d 127.0.0.1 -j ACCEPT
-A INPUT -p tcp --dport 3000 -j DROP #DROP( discarded )
-A OUTPUT -p tcp --sport 5900:5930 -j DROP
-A INPUT -j REJECT --reject-with icmp-host-prohibited #REJECT( Refuse )
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
5、 ... and 、 Configure and save rules directly
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT # add to
iptables -D INPUT -p tcp -m tcp --dport 80 -j ACCEPT # clear
iptables -L # see
preservation
service iptables save
It will take effect permanently after restart
service iptables restart
6、 ... and 、 Reference link
iptables Configuration rules
About iptables Rule configuration method
linux Check your settings in the system iptables The rules
版权声明
本文为[Drunken Xiaobai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231829110764.html
边栏推荐
- Cygwin64 right click to add menu, and open cygwin64 here
- 【ACM】509. 斐波那契数(dp五部曲)
- NVIDIA Jetson: GStreamer and openmax (GST OMX) plug-ins
- WIN1 remote "this may be due to credssp encryption Oracle correction" solution
- Daily network security certification test questions (April 14, 2022)
- C language simulates entering and leaving the stack, first in first out, first in first out, shared memory
- 串口调试工具cutecom和minicom
- Permission management with binary
- 【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))
- Dynamically add default fusing rules to feign client based on sentinel + Nacos
猜你喜欢
Robocode tutorial 7 - Radar locking
listener.log
MATLAB小技巧(6)七种滤波方法比较
logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
Function recursion and solving interesting problems
Nodejs installation
JD-FreeFuck 京東薅羊毛控制面板 後臺命令執行漏洞
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
C medium? This form of
Robocode tutorial 8 - advanced robot
随机推荐
Can filter
listener.log
Imx6 debugging LVDS screen technical notes
According to the result set queried by SQL statement, it is encapsulated as JSON
硬核解析Promise對象(這七個必會的常用API和七個關鍵問題你都了解嗎?)
With the use of qchart, the final UI interface can be realized. The control of qweight can be added and promoted to a user-defined class. Only the class needs to be promoted to realize the coordinate
函数递归以及趣味问题的解决
Kettle paoding jieniu Chapter 17 text file output
Cells in rust share variable pointers
Dynamically add default fusing rules to feign client based on sentinel + Nacos
数据库上机实验四(数据完整性与存储过程)
14个py小游戏源代码分享第二弹
14 py games source code share the second bullet
Mysqldump backup database
Rust: how to match a string?
STM32 learning record 0008 - GPIO things 1
Keil RVMDK compiled data type
机器学习理论之(8):模型集成 Ensemble Learning
22年字节跳动飞书人力套件三面面经
串口调试工具cutecom和minicom