当前位置:首页 > 技术分享

Centos 服务器禁止 IP访问/ IP黑名单

admin3年前 (2023-02-02)技术分享3167

一、iptables 防火墙

yum install iptables-services #2.安装 iptables 防火墙
systemctl enable iptables# 3.设置开机自启
service iptables [save|stop|start|restart]
 # 4.基本使用:
 # []里分别对应保存,停止,启动和重启

二、iptables开启某些端口可以进来

# 因为我们防火墙刚开,默认端口都是屏蔽的,会发现网站访问不了

# 1.我们需要放行端口,这里先放行 80 、 443 和 22 端口

 

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -j ACCEPT

三、iptables禁止某些IP访问本机

# 屏蔽IP-屏蔽 42.118.6.207   的入请求

iptables -I INPUT -s 42.118.6.207 -j DROP

四、查看出当前的防火墙规则

iptables -L -n  --line-number

# 例如:删除INPUT的第一条规则用如下命令。这个1就是行号

iptables -D INPUT 1

 

再执行查看即可看到上述规则已删除。

iptables -L -n  --line-number

扫描二维码推送至手机访问。

版权声明:本文由小刚刚技术博客发布,如需转载请注明出处。

本文链接:https://blog.bitefu.net/post/462.html

分享给朋友:

“Centos 服务器禁止 IP访问/ IP黑名单” 的相关文章

PIP 更换国内安装源linux/windows

pip国内的一些镜像  阿里云 http://mirrors.aliyun.com/pypi/simple/   中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/   豆瓣(…

七牛html js上传带进度条源码

七牛html js上传带进度条源码注册链接https://s.qiniu.com/uM7RJv完整代码下载:https://n802.com/f/349707-489018989-c141f6(访问密码:5036)http://www.yi…

Chrome 最全历史版本下载以及chromedriver下载

https://vikyd.github.io/download-chromium-history-version/#/ https://dl.lancdn.com/landian/soft/chrome/m/ chromedriver的版…

​CentOS 安装libsodium 支持 crypto_aead_aes256gcm_decrypt 兼容php5.6,php7.2

微信小微商户下载证书返回的密文用 AEAD_AES_256_GCM 算法 解密的方法。其中用到了 string sodium_crypto_aead_aes256gcm_decrypt ( string $ci…

Lodop、C-Lodop 95版本chrome跨域请求问题 has been blocked by CORS policy: Response 解决

1、打开chrome://flags/#site-isolation-trial-opt-out2、搜索Block insecure private network requests3、设置disabled4、重启chrome…

Bootstrap动态切换主题(通用)

bootstrap有个网站叫做bootswatch,其中已经设计了一些很美的主题:要想使用也是很简单的,只需要下载其中的bootstrap.css或者bootstrap.min.css并覆盖到自己项目的对应文件就行了。如果你想动态切换的话,…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。