Home > System Tutorial > LINUX > How to disable and enable IP address in CentOS7?

How to disable and enable IP address in CentOS7?

WBOY
Release: 2024-01-04 08:16:31
forward
1663 people have browsed it

1. Block ip

I haven’t logged into my VPS for a long time. Today I used Xshell to log in and saw the Last Failed Login. After a closer look, I saw an unknown IP trying to crack my VPS. After confirming with my partner that it was not his IP, I decided to fix this ip is blocked.

CentOS7如何封停 解封IP?

(Picture 1: An unknown IP tried to log in to my VPS)

CentOS7 command to block ip: iptables

Usage (note case-sensitive):

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

CentOS7如何封停 解封IP?

(Figure 2: Usage of iptables blocking IP)

Parameter -I means Insert (add), followed by rules, INPUT means inbound, ***.***.***.*** means the IP to be blocked, DROP means giving up the connection . After successfully executing the command, there will be no prompt. To view the blocked IP list, execute the command:

iptables --list

CentOS7如何封停 解封IP?

(Figure 3: Use the list parameter to view the IP addresses blocked by DROP. The blocked IP addresses are below the source)

2. Unblock ip

1. To unblock, replace -I with -D. The premise is that iptables already has this record:

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

2. If you want to clear the blocked IP address, you can enter:

iptables --flush

The above is the detailed content of How to disable and enable IP address in CentOS7?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
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