大网数据广告活动
服务器运维问答

SAMBA shares are not working unless I enter an iptables command at every boot

· 52CE 我爱测

I have recently enabled ufw in Linux and found that in order for my Samba shares to mount correctly, I need to enter this command sudo iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns However, it is s…

问题原文

原帖链接 · Razor · CC BY-SA 4.0

I have recently enabled ufw in Linux and found that in order for my Samba shares to mount correctly, I need to enter this command

sudo iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns

However, it is somehow forgotten at the next reboot and I have to enter it every time.

Is there a way to make this iptables command stick?

已采纳解答

原帖链接 · Esa Jokinen · CC BY-SA 4.0

Iptables rules are not persistent, and UFW cannot read and save rules added directly using iptables. Instead, you should be using the UFW to add the rules, e.g.

sudo ufw allow 134/udp

Or if you have Samba application rules installed:

sudo ufw allow samba

This will allow all ports used by Samba, as the application rule is something like:

[Samba] 
title=LanManager-like file and printer server for Unix 
description=The Samba software suite is a collection ...
ports=137,138/udp|139,445/tcp

You could also make iptables rules persistent by installing iptables-persistence and using iptables-save, but it is not recommended to mix this with UFW.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-11-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。