端口 25 — SMTP (TCP)
什么是端口 25?
简单邮件传输协议
这是 well-known 端口(0–1023),常被 SMTP 等核心服务使用。 · RFC 5321
什么情况下需要开放端口 25?
Open only on mail servers that receive email from other mail servers (MX record). ISPs typically block port 25 on residential connections. Use port 587 for sending from applications or mail clients.
常见用途与软件
- Postfix
- Exim
- Sendmail
- Microsoft Exchange Server
- Haraka
安全
Port 25 is exploited by spammers when misconfigured as an open relay. Require STARTTLS for all connections. Enable SPF, DKIM, and DMARC DNS records to prevent spoofing. ISPs block port 25 on residential connections — use a dedicated mail server or relay service (SendGrid, Mailgun) if sending bulk email.
端口 25 安全吗?
开放端口会增加攻击面。安全性取决于 SMTP 的配置。
此端口是自动化攻击的活跃目标。除非需要 SMTP,否则保持关闭,并在防火墙中将访问限制为已知的 IP 地址段。
测试任意主机的端口 25 连通性。
开放端口 25
要允许到端口 25 (SMTP) 的入站连接,请配置防火墙并在路由器上添加端口转发规则,指向设备的本地 IP 地址。
打开 Windows Defender 防火墙 → 高级设置 → 入站规则 → 新建规则 → 端口 → TCP → 特定本地端口: 25 → 允许连接 → 命名并保存规则。
netsh advfirewall firewall add rule name="Open Port 25" dir=in action=allow protocol=tcp localport=25sudo ufw allow 25/tcpsudo iptables -A INPUT -p tcp --dport 25 -j ACCEPT登录路由器(192.168.1.1 或 192.168.0.1)→ 端口转发 → 添加新规则: 协议 TCP, 外部端口 25, 内部 IP: 设备的本地 IP, 内部端口 25 → 保存。
如何关闭端口 25
若不需要 SMTP,请在防火墙或路由器中阻止该端口。
要在 Windows 上屏蔽端口 25,请以管理员身份在 PowerShell 或命令提示符中运行以下命令:
netsh advfirewall firewall add rule name="Block Port 25" dir=in action=block protocol=tcp localport=25执行:sudo ufw deny 25/tcpsudo iptables -A INPUT -p tcp --dport 25 -j DROP删除或禁用端口 25 的端口转发规则。
常见问题
端口 25 用于什么?▾
25 端口是 SMTP 的标准 TCP 端口。它被需要接受该服务入站连接的服务器和应用程序所使用。是否需要开放取决于您是否在运行 SMTP 服务器——如果没有,应保持关闭。
保持端口 25 打开安全吗?▾
开放的 25 端口会扩大攻击面。如果您没有主动运行 SMTP,请在防火墙中关闭此端口并删除端口转发规则。如果 SMTP 需要可访问,请将访问限制为已知 IP 地址并保持软件更新。