当前位置:网站首页>Iptables only allows the specified IP address to access the specified port
Iptables only allows the specified IP address to access the specified port
2022-07-07 16:12:00 【Gegwu MMQ!!】
First , Clear all presets
iptables -F# Clear preset table filter Rules of all rule chains in iptables -X# Clear preset table filter User defined rules in the chain
1.
secondly , Setting allows only specified ip Address access specified port
iptables -A INPUT -s xxx.xxx.xxx.xxx -p tcp --dport 22 -j ACCEPT iptables -A OUTPUT -d xxx.xxx.xxx.xxx -p tcp --sport 22 -j ACCEPT iptables -A INPUT -s xxx.xxx.xxx.xxx -p tcp --dport 3306 -j ACCEPT iptables -A OUTPUT -d xxx.xxx.xxx.xxx -p tcp --sport 3306 -j ACCEPT
1.
The top two , Please note that –dport For the target port , When data enters the server from the outside as the target port ; conversely , Data from the server is the data source port , Use --sport
Empathy ,-s Is to specify the source address ,-d Is to specify the destination address .
then , Close all ports
iptables -P INPUT DROP iptables -P OUTPUT DROP iptables -P FORWARD DROP
1.
Last , Save the current rule
/etc/rc.d/init.d/iptables save service iptables restart
1.
such iptables The rule setting of applies to only acting as MySQL Server management and maintenance , The external address does not provide any services .
If you wish yum If it works , You also need to add the following , allow DNS Requested 53 port , Allow to download randomly generated high ports
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -p udp --s
To open 8080 Port as an example :
Mode one :
Log in and copy
1、 Turn on the firewall
systemctl start firewalld
2、 Open designated port
firewall-cmd --zone=public --add-port=1935/tcp --permanent
Meaning of order :
–zone # Scope
–add-port=1935/tcp # Add port , The format is : port / Communication protocol
–permanent # permanent , Failure after restart without this parameter
3、 service iptables restart
firewall-cmd --reload
4、 View port number
netstat -ntlp // View all of the current tcp port ·
netstat -ntulp |grep 8080 // View all 8080 Port usage
Mode two :
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
Mode three :
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
service iptables restart
边栏推荐
- AE learning 01: AE complete project summary
- Vite path alias @ configuration
- [excelexport], Excel to Lua, JSON, XML development tool
- Three. JS introductory learning notes 03: perspective projection camera
- It's different for rich people to buy a house
- Description of vs common shortcut keys
- Shipping companies' AI products are mature, standardized and applied on a large scale. CIMC, the global leader in port and shipping AI / container AI, has built a benchmark for international shipping
- js中复选框checkbox如何判定为被选中
- 95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
- Odoo集成Plausible埋码监控平台
猜你喜欢
You Yuxi, coming!
Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
Vs tool word highlight with margin
强化实时数据管理,英方软件助力医保平台安全建设
Postman generate timestamp, future timestamp
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
AB package details in unity (super detail, features, packaging, loading, manager)
随机推荐
Mysql database basic operation DQL basic query
What else can an ordinary person do besides working in a factory to make money?
星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
分类模型评价标准(performance measure)
招标公告:2022年云南联通gbase数据库维保公开比选项目(第二次)比选公告
神经网络c语言中的指针是怎么回事
prometheus api删除某个指定job的所有数据
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
Notification uses full resolution
Eye of depth (VII) -- Elementary Transformation of matrix (attachment: explanation of some mathematical models)
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
47_Opencv中的轮廓查找 cv::findContours()
AB package details in unity (super detail, features, packaging, loading, manager)
统计学习方法——感知机
应用程序和matlab的通信方式
航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
Postman generate timestamp, future timestamp
Three. JS introductory learning notes 04: external model import - no material obj model