Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to block and unblock IP by CentOS7

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to block and unblock CentOS7 IP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

First, block and stop ip

I haven't logged in to my VPS for a long time. I logged in with Xshell today and saw Last Failed Login. After taking a closer look, I found that some unknown ip tried to crack my VPS. After confirming with my partner that it was not his ip, I decided to block this ip.

(figure 1: an unknown ip is trying to log in to my VPS)

CentOS7's command to block ip: iptables

How to use (pay attention to case sensitivity):

Iptables-I INPUT-s * *.-j DROP

(figure 2:iptables 's use of blocking ip)

The parameter-I indicates Insert (add), followed by rules, INPUT indicates inbound, and * *. * indicates that the IP,DROP to be blocked means to abandon the connection. After the command is executed successfully, you will not be prompted. To view the list of blocked ip, execute the command:

Iptables-list

(figure 3: use the list parameter to view the ip address blocked by DROP. Below the source is the blocked ip address)

2. Unblock ip

1. To unblock, replace-I with-D, as long as iptables already has this record:

Iptables-D INPUT-s *. *-j DROP

two。 If you want to clear the sealed IP address, type:

Iptables-flush

This is the end of the article on "how to block and unblock CentOS7 IP". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report