服务器笔记
1 subscriber
10 photos
3 links
Download Telegram
Channel created
Channel photo updated
🔛windows篇
✅Windows Server 2012/2016/2019 設置多用戶遠程桌面設置方法
1、首先需要先安裝遠程桌面服務
2、配置組策略,運行框輸入 gpedit.msc,打開 計算機配置–>管理模板—>windows組件—>
然後在右邊的菜單中選擇遠程桌面服務;雙擊打開。雙擊遠程桌面會話主機 –>連接,點擊限製連接的數量,設置如下:
3、這樣設置就完成了。

這樣設置遠程多用戶只有120天期限,要破解120天限製,還需要配置遠程桌面授權。

能成功的前提:系統是激活的。
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1
🔛禁PING某個特定IP
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1
🚩調整Linux描述符
文件描述符是由無符號整數表示的句柄,進程使用它來標識打開的文件。文件描述符與包括相關信息(如文件的打開模式,文件的位置類型,文件的初始類型等) 的文件對象相關聯,這些信息被稱作文件的上下文。文件描述符的有效範圍是0 到 OPEN_MAX.


對於內核而言,所有打開的文件都是通過文件的描述符引用的.當打開一個現有文件或創建一個新文件時,內核向進程返回一個文件描述符,當讀或寫一個文件時,使用 open 或 create 返回的文件描述符標識該文件,並將其作為參數傳遞給 read 或 write.


查看系統文件描述符設置的情況可以使用下面的命令,文件描述符大小默認是1024.
ulimit -n
對於高並發的業務 Linux 服務器來說,這個默認的設置值是不夠的,需要調整


🟢調整方法一:
調整系統文件描述符為65535
echo ‘* – nofile 65535’ >>/etc/security/limits.conf
tail -l /etc/security/limits.conf


🟢調整方法二:
直接把 ulimit -SHn 65535命令加入/etc/rc.d/rc.local,用以設置每次開機啟動時配置生效,命令如下:
echo ” ulimit -HSn 65535″ >>/etc/rc.d/rc.local
echo ” ulimit -s 65535″ >>/etc/rc.d/rc.local
Please open Telegram to view this post
VIEW IN TELEGRAM
❤1
✅修复宝塔节点的命令

官方参考链接:https://www.bt.cn/bbs/forum.php?mod=viewthread&tid=87257
Please open Telegram to view this post
VIEW IN TELEGRAM
✅tcping 的使用方法

功能:IP不通的情况下,可以利用tcping 端口, 2000ms为不通
安装:将tcping工具下载后解压得到tcping.exe文件,将tcping.exe文件放到C盘:“C:\Windows\System32”目录下即可。
官网:https://elifulkerson.com/projects/tcping.php

例如 检测80端口
tcping 110.242.68.66 80
tcping baidu.com 80

时间为:2000ms表示不通
Please open Telegram to view this post
VIEW IN TELEGRAM
防火墙连接数监控与封禁

一、查询当前连接数
----------------------------
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

输出示例:
1 192.168.1.100
3 10.0.0.5
256 123.6.49.50 ← 连接数过多,可疑IP段,需要关注
300 27.115.124.6 ← 连接数过多,可疑IP段,需要关注

二、封禁操作
-----------
1. 封禁单个IP:
iptables -I INPUT -s 可疑IP地址 -j DROP

2. 封禁整个IP段:
iptables -I INPUT -s 可疑IP段/24 -j DROP

3. 限制连接数(推荐方式):
iptables -I INPUT -p tcp -m connlimit --connlimit-above 15 --connlimit-mask 24 -s 可疑IP段1/24 -j DROP
iptables -I INPUT -p tcp -m connlimit --connlimit-above 15 --connlimit-mask 24 -s 可疑IP段2/24 -j DROP
iptables -I INPUT -p tcp -m connlimit --connlimit-above 15 --connlimit-mask 24 -s 可疑IP段3/24 -j DROP

三、查看防火墙规则
-----------------
iptables -L INPUT -n --line-numbers

四、永久保存规则(重要!)
-----------------------
根据系统选择对应的命令:

Debian/Ubuntu 系统:
# 安装保存工具
apt update && apt install iptables-persistent -y

# 保存规则
netfilter-persistent save

CentOS 7 系统:
# 安装保存工具
yum install iptables-services -y

# 保存规则
service iptables save

# 启用开机启动
systemctl enable iptables

CentOS 8/Rocky Linux 系统:
# 安装保存工具
dnf install iptables-services -y

# 保存规则
service iptables save

# 启用开机启动
systemctl enable iptables

五、完整操作流程示例
-------------------
场景:发现某个IP连接数异常

步骤1:查询连接数
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

步骤2:封禁可疑IP
iptables -I INPUT -s 可疑IP地址 -j DROP

步骤3:确认规则
iptables -L INPUT -n --line-numbers

步骤4:永久保存(根据系统选择)
Debian/Ubuntu: netfilter-persistent save
CentOS: service iptables save

六、解除封禁
-----------
1. 查看规则行号:
iptables -L INPUT -n --line-numbers

2. 删除规则(例如删除第3行):
iptables -D INPUT 3

3. 保存更改(根据系统选择):
Debian/Ubuntu: netfilter-persistent save
CentOS: service iptables save

七、一键监控脚本
---------------
创建脚本:
cat > /root/monitor.sh << 'EOF'
#!/bin/bash
echo "=== 当前连接数最多的IP ==="
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head -10
echo -e "\n=== 当前防火墙规则 ==="
iptables -L INPUT -n --line-numbers | grep DROP
EOF

给脚本执行权限:
chmod +x /root/monitor.sh

运行监控:
/root/monitor.sh

八、快速参考命令
-----------------
查询连接数 :netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
封禁单个IP :iptables -I INPUT -s IP地址 -j DROP
封禁IP段 :iptables -I INPUT -s IP段/24 -j DROP
限制连接数 :iptables -I INPUT -p tcp -m connlimit --connlimit-above 15 -s IP段/24 -j DROP
查看规则 :iptables -L INPUT -n --line-numbers
保存规则(Debian):netfilter-persistent save
保存规则(CentOS):service iptables save
删除规则 :iptables -D INPUT 行号

九、重要提醒
-----------
1. 操作前先查询:封禁前一定要先确认IP地址
2. 及时保存:修改规则后必须执行保存命令,否则重启后规则会丢失
3. 谨慎操作:不要封禁自己的IP地址,否则会无法连接服务器
4. 连接数限制更友好:相比直接封禁,限制连接数对正常用户更友好
5. 先测试再保存:建议先测试规则效果,确认无误后再保存
6. 注意系统区别:Debian/Ubuntu和CentOS的保存命令不同

十、常见问题
-----------
Q: 如何知道哪个IP是我自己的?
A: 使用命令:curl ifconfig.me 查看自己的公网IP

Q: 封禁后如何确认生效?
A: 使用监控脚本或再次查询连接数确认

Q: 规则保存失败怎么办?
A: Debian/Ubuntu: 检查iptables-persistent是否安装
CentOS: 检查iptables-services是否安装,或尝试:iptables-save > /etc/sysconfig/iptables

Q: 如何查看系统版本?
A: 使用命令:cat /etc/os-release

========================================
适用系统:Debian/Ubuntu/CentOS/Rocky Linux
========================================