Monday, April 23, 2007

IP Security for Samba Server

I have linux samba server for folder sharing in my Local Area Network (LAN). Then I need only restricted IP addresses can access the specific folder. I do following simple steps:


1. I modify the configuration file (smb.conf) with the root user.

# vi /etc/samba/smb.conf

[private]
comment = Plita stuff
path = /data/private
valid users =plita
public = no
writable = yes
printable = no
create mask = 0765
hosts allow = 172.26.15.71 172.26.15.200 172.26.15.212

I add the IP addresses in the entry of hosts allow and sparate the IP with space if the IP that granted to access the folder more than one. Then save the changes.

2. I restart the samba service with the following command line:

# /etc/init.d/smb restart

In my screen then displayed message like the below:

Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]

3. Done. After this, only from the IP that has listed, the folder could be accessed.

No comments: