web-dev-qa-db-ja.com

SAMBAでIPを使用して読み取り、書き込み権限を付与する方法

Smb.confを使用して、SAMBAのユーザーではなくIPに基づいて読み取りおよび書き込みアクセスを許可したい

これは、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 =

しかし、Sambaは変更を取得していません。 ExplorerまたはNautilusからアクセスしようとすると、エラーが発生するためです。

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

ここで何が間違っているのかアドバイスをください

4
OmiPenguin

オプション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

アイデアは、同じ名前を2回共有することですが、書き込み/読み取りの権利とホストの許可が異なります。これが構成にある唯一の共有である場合は、冗長性を減らすためにいくつかのオプション/設定を[global]にエクスポートできます。

アクセスチェック:testparm /path/to/smb.conf hostname hostIP

1
xx4h

私の答えは後ろ向きでなければなりませんでした

そのため、最初にメインの読み取り専用会議、次に書き込み可能会議を設定します。

これがconfです:

[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
0