如何在 SAMBA 中使用 IP 授予读取、写入权限

如何在 SAMBA 中使用 IP 授予读取、写入权限

我想使用 smb.conf 基于 IP 而不是 SAMBA 中的用户授予读写访问权限

这是我从 smb.conf 文件复制的文本。

[TEST]
        comment = test
        path = /mnt/vg-stg/storage/test
        read only = no
        writeable = yes
        oplocks = yes
        level2 oplocks = yes
        force security mode = 0
        dos filemode = yes
        dos filetime resolution = yes
        dos filetimes = yes
        fake directory create times = no
   browseable = yes
   csc policy = manual
   veto oplock files = /*.mdb/*.MDB/*.dbf/*.DBF/
   veto files = /*:Zone.Identifier:*/
   store dos attributes = yes
   map acl inherit = yes
        create mode = 0777
        directory mode = 2777
        printable = no
        guest ok = yes
        hosts allow = 10.20.20.213
        #hosts readonly allow =

[TEST]
        comment = test
        path = /mnt/vg-stg/storage/test
        read only = yes
        writeable = no
        oplocks = yes
        level2 oplocks = yes
        force security mode = 0
        dos filemode = yes
        dos filetime resolution = yes
        dos filetimes = yes
        fake directory create times = no
   browseable = yes
   csc policy = manual
   veto oplock files = /*.mdb/*.MDB/*.dbf/*.DBF/
   veto files = /*:Zone.Identifier:*/
   store dos attributes = yes
   map acl inherit = yes
        create mode = 0777
        directory mode = 2777
        printable = no
        guest ok = yes
        hosts allow = 10.20.20.147
        #hosts readonly allow =

但桑巴并没有接受这些变化。因为当我尝试从资源管理器或 Nautilus 访问时,它给了我错误

Could not display "smb://XXX.XXX.XXX.XXX/Reports
The file is of an unknown type

请给我建议我在这里做错了什么

答案1

我认为选项hosts readonly allowhosts write list存在不存在。顺便说一句:我的 samba/testparm 也没有。理论上这应该符合您的预期:

[mainBak]
comment = Main Backup Writeable
    path = /mnt/vg-stg/storage/Main_Backup
    read only = no
    writeable = yes
    oplocks = yes
    level2 oplocks = yes
    force security mode = 0
    dos filemode = no
    dos filetime resolution = no
    dos filetimes = no
    fake directory create times = no
browseable = yes
csc policy = manual
veto oplock files = /*.mdb/*.MDB/*.dbf/*.DBF/
veto files = /*:Zone.Identifier:*/
store dos attributes = yes
map acl inherit = yes
    create mode = 0777
    directory mode = 2777
    printable = no
    guest ok = yes
    hosts allow = 10.91.12.109 10.91.12.115 10.91.12.95 10.91.12.67 10.91.12.109 10.91.12.115 10.20.20.147

[mainBak]
comment = Main Backup Readonly
        path = /mnt/vg-stg/storage/Main_Backup
        read only = yes
        writeable = no
        oplocks = yes
        level2 oplocks = yes
    force security mode = 0
    dos filemode = no
    dos filetime resolution = no
    dos filetimes = no
    fake directory create times = no
browseable = yes
csc policy = manual
veto oplock files = /*.mdb/*.MDB/*.dbf/*.DBF/
veto files = /*:Zone.Identifier:*/
store dos attributes = yes
map acl inherit = yes
    create mode = 0777
    directory mode = 2777
    printable = no
    guest ok = yes
    hosts allow = 10.20.20.0/24 10.20.50.0/24 172.16.0.0/16 192.168.0.0/16 10.91.12.252 10.20.20.94 10.91.12.46 10.91.12.197 10.91.12.87 10.91.12.106 10.91.12.110 10.91.12.12 10.91.12.108 10.91.12.62 10.91.12.129 10.91.12.127 10.91.12.128 10.91.12.50 10.91.12.142

想法是具有相同的名称以共享两次,但具有不同的写/读权限和主机允许。如果这是您的配置中唯一的共享,您可以导出一些选项/设置以[global]减少冗余。

访问检查你可以这样做:testparm /path/to/smb.conf hostname hostIP

答案2

我的答案必须是倒退的

因此,我首先设置主只读配置,然后设置可写配置。

这是会议:

[ShareName]

comment = RO
path = /path
available = yes
hosts allow = 127.0.0.1 192.168.1. 10. EXCEPT 192.168.1.203
read only = yes
browseable = yes
public = yes
writable = no


[ShareName]

comment = WR
path = /path
available = yes
hosts allow = 192.168.1.203
read only = no
browseable = yes
public = yes
writable = yes

相关内容