Banning IPs from SMB?

Discussion in 'OS X' started by yg17, Apr 27, 2005.

  1. macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #1
    I'm on a college network, and everyone connects to everyone elses computer to download stuff. Well, uh, I have some, umm, legal files shared, no illegal piracy going on here. Problem is, there are a few leeches on the network who download like 10 gigs of legal files and don't share anything in return. So, instead of allowing them to do this which then slows down my computer, I want to ban them :D I can use smbstatus to see who's downloading, use tcpdump to get their IP, but how would I go about banning them from connecting via SMB to my shared files? Thanks
     
  2. macrumors 68030

    mnkeybsness

    Joined:
    Jun 25, 2001
    Location:
    Moneyapolis, Minnesota
    #2
    ha ha ha... yeah... maybe your stuff is legal, but the stuff they upload isn't legal... nice try at covering yourself :D

    Sorry, but I don't know if you can do what you want or not.
     
  3. macrumors 6502a

    Joined:
    Apr 19, 2005
    #3
    i'm not sure of a specific thing in samba that will do this and a quick google search unveils nothing interesting, maybe my google-fu sucks tonight. You could add the IP to /etc/hosts.deny... at least that's in linux... might be something similiar ... xinetd has this ability as well
     
  4. macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #4
    Firewall settings ... shouldn't be too complicated, but I have never done it, so I'm not really sure.
     
  5. macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #5
    I have tested the /etc/hosts.deny approach, it is used by tcpd and man tcdp says:

    "The tcpd program can be set up to monitor incoming requests for telnet,
    finger, ftp, exec, rsh, rlogin, tftp, talk, comsat and other services
    that have a one-to-one mapping onto executable files.
    "

    I wastn't able to make it work for apple file sharing, but it seems to work with smb and ssh.

    What you do is quite simple. The hosts.allow and hosts.deny files doesn't exist by default, but the tcpd service will start working as soon as both files are created. Open a terminal:

    Create an empty allow file
    sudo touch /etc/hosts.allow

    Create and edit the deny file
    sudo pico /etc/hosts.deny

    This will start the simple editor pico that will let you edit and save the file. For each IP that you wish to block, enter a line like this:
    ALL: the.ip.to.block

    The ALL: means to block all services for that ip.

    That's it, the "offender" should now be blocked.
     
  6. Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #6
    Learn to use ipfw from the command line, or use BrickHouse/SunShield to control it. But your line should look like this:

    deny all from 123.123.123.123 to any in

    Where 123.123.123.123 is the IP of the offending party.

    OR

    Check out /etc/smb.conf, the smb.conf man page, and the "host deny" section.
     
  7. macrumors 601

    Westside guy

    Joined:
    Oct 15, 2003
    Location:
    The soggy part of the Pacific NW
    #7
    You can do all sorts of interesting things with Samba. Go to samba.org and read the documentation for smb.conf.
     

Share This Page