LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-27-2014, 08:32 AM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
Can you limit a specific samba share to certain IPs?


I know in smb.conf you can limit all samba shares to certain IPs with "hosts allow", but is there a way to do it for only a specific share too?
 
Old 02-27-2014, 08:47 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,749

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
Yes, as far as I know hosts allow is valid on a per share basis.
 
1 members found this post helpful.
Old 02-27-2014, 08:51 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Just depends on where you put that 'hosts allow'

if you put it under global, then it will only allow those hosts 'globally'

if you put it under a share config, then it will only restrict ip's to that share
 
1 members found this post helpful.
Old 02-27-2014, 09:03 AM   #4
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Oh ok, so it's valid under both, but if you do it at the share level, you must do it for all then.

So say i have three shares, but I only do an allow hosts under two of them, does that mean the one without allow hosts is then wide open, or closed off to everyone due to the lack of allow hosts?
 
Old 02-27-2014, 09:09 AM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
So, searching for an example, I actually found an explanation for what you want: https://bbs.archlinux.org/viewtopic.php?id=108500

And here is the gist of it (other things removed for brevity, this is not a working example)
Code:
#smb.conf file
[global]
    workgroup = WHATEVER
    security = share
    include = /etc/samba/smbshared.conf

#smbshared.conf file
[Shared]
    path = /home/Shared
    hosts allow = 192.168.1.86

[Music]
    path = /home/Music
Explanation: Globally, there is no hosts_allow specified. So the default behavior is to allow all hosts. At the share level, 'shared' only allows 1.86 to connect to it and nothing else, but 'music' on the other hand inheritcs the global settings, which allows any ip to connect to it.

Last edited by szboardstretcher; 02-27-2014 at 09:10 AM.
 
1 members found this post helpful.
Old 02-27-2014, 10:38 AM   #6
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
awesome, thanks sz!

Now if I can just figure out how to limit a specific share so it only shows/allows a certain total disk space, I'd be all set. Trying to tweak some existing servers but really not sure what's possible and what isn't yet. Really appreciate the help on this hosts allow thing.
 
Old 02-27-2014, 10:46 AM   #7
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
No problemo.

Simple answer: Put each share on its own partition. Size the partition accordingly.

Advanced reminder: Make it LVM, so you can easily expand your disk when you run out of space.

Last edited by szboardstretcher; 02-27-2014 at 10:47 AM.
 
1 members found this post helpful.
Old 02-27-2014, 11:01 AM   #8
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
I was afraid that was going to be the only answer. Was hoping there was a way to do it via samba config, since this is an existing server I'm hoping I don't need to reload.
 
Old 02-27-2014, 11:06 AM   #9
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Well the only other way I know how is by using quotas. Now, Samba doesn't directly know about these quotas, instead it is configured and handled in the user space by quotad. Its involved, and possibly complicated based on your linux level. But here is the first guide i found:

http://www.linuxhomenetworking.com/w...s#.Uw9wA9xb11s

Im not sure how up to date that is, so you should certainly look up the documentation regarding quotas for your specific distro!

TLDR,.. you can enable quotas on a disk and set up each samba mount to use a specific user that has a disk quota.

Last edited by szboardstretcher; 02-27-2014 at 11:08 AM.
 
1 members found this post helpful.
Old 02-27-2014, 11:29 AM   #10
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
That might be a clever way to do it, force the mount to use a user that has a quote. I'll have to dig into it, but that's a pretty clever idea. thanks again!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Allow Specific File types on Samba Share ? keysys Linux - Server 1 12-28-2012 07:58 PM
My samba share is blocking specific extensions. rpg2 Linux - Security 2 04-13-2005 09:57 AM
how to define a specific range of IPs and/or multiple IPs in an iptables rule?... TheHellsMaster Linux - Security 9 09-20-2004 10:06 AM
samba windows share file size limit Axion Linux - Software 2 04-04-2004 02:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration