当前位置:网站首页>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
边栏推荐
- Shader basic UV operations, translation, rotation, scaling
- [excelexport], Excel to Lua, JSON, XML development tool
- three.js打造酷炫下雪效果
- Use moviepy Editor clips videos and intercepts video clips in batches
- 过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
- LeetCode3_ Longest substring without duplicate characters
- Description of vs common shortcut keys
- 【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
- Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
猜你喜欢
2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
C4D learning notes 2- animation - timeline and time function
Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
【微信小程序】Chapter(5):微信小程序基础API接口
torch. Numel action
SPI master rx time out中断
随机推荐
Mysql database backup script
Dotween -- ease function
Rongyun won the 2022 China Xinchuang digital office portal excellence product award!
hellogolang
There are many ways to realize the pause function in JS
招标公告:2022年云南联通gbase数据库维保公开比选项目(第二次)比选公告
AE learning 01: AE complete project summary
航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
asyncio 概念和用法
讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
Virtual memory, physical memory /ram what
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
Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
通知Notification使用全解析
[wechat applet] Chapter (5): basic API interface of wechat applet
leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
Plate - forme de surveillance par étapes zabbix
markdown公式编辑教程