Re: Iptables rule for windows file sharing?

From: Temlakos (temlakos_at_gmail.com)
Date: 01/29/05

  • Next message: Trey Sizemore: "Conflicting yum repositories"
    Date: Sat, 29 Jan 2005 16:45:08 -0500
    To: cjlesh@gmail.com, For users of Fedora Core releases <fedora-list@redhat.com>
    
    

    On Fri, 28 Jan 2005 19:50:02 +0100, cjlesh
    <no-reply-gw@fcp.homelinux.org> wrote:
    > Hey all:
    >
    > I have a laptop running Fedora Core 3 and a dekstop with Widows XP, both connected via a Linksys router.
    >
    > I am trying to figure out a way to allow the laptop 'see' the shared directories on the Windows machine. If I disable the Fedora firewall, it works.
    >
    > I would like to do this without disabling the firewall.
    > A google search turns up to following command:
    >
    > iptables -A INPUT -p ALL -i eth0 -s 192.168.0.1 --destination-port 137:139 -j ACCEPT
    >
    > however this results in an error.
    >
    > Any help on a reasonable firewall rule to allow windows share traffic on my local network only?

    I finally found the answer, after experimenting with this all day. My
    insight comes from running an Ethereal capture of a three-minute
    session, during which I browsed a Samba server (actually, two of
    them--my own machine and another machine on the network) and printed
    to a Samba printer (on the other machine).

    In your iptables rule set, make sure you have the following as your last rules:

    -A RH-Firewall-1-INPUT -p udp -m udp -s 192.168.1.0/24 --dport 137 -j ACCEPT
    -A RH-Firewall-1-INPUT -p udp -m udp -s 192.168.1.0/24 --dport
    32700:32800 -j ACCEPT
    -A RH-Firewall-1-INPUT -p tcp -m tcp -s 192.168.1.0/24 --dport 139 -j ACCEPT
    -A RH-Firewall-1-INPUT -p tcp -m tcp -s 192.168.1.0/24 --dport 445 -j ACCEPT
    -A RH-Firewall-1-INPUT -p tcp -m tcp -s 192.168.1.0/24 --dport
    32800:32900 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    Note carefully: insert all rules quoting 192.168.1.0/24 as the source
    (-s) directly above the -m state rule accepting ESTABLISHED and
    RELATED states.

    The above are for a network based on a Linksys router having on it a
    Windows machine and/or any UNIX/Linux box running the Samba services.

    The rationale is this:

    UDP Port 137: NetBIOS name service.
    UDP Port range 32700:32800: the upper end of a NetBIOS name service
    conversation.
    TCP Port 139: NetBIOS-SSN.
    TCP Port 445: Microsoft-DS
    TCP Port range 32800:32900: the upper end of all SMB TCP conversations.

    Open these ports, and their ranges, but /only/ for 192.168.1.0/24 as a
    source, and you should have Windows file and print sharing, but will
    /not/ have to worry about anyone detecting you on the outside.

    If I have time, I might refine this to tighten up the range. But as it
    stands now, it works, and it's a lot more narrow than simply opening
    my system up to /everything/ having 192.168.1.0/24 as its source.

    My next experiment will probably be to restrict everything to
    transactions having UDP port 137 or TCP ports 139 and 445 as /either
    source or destination port./ Right now, I was concerned strictly with
    opening every destination port that might come up. I have something
    that works, and is less vulnerable.

    Temlakos

    -- 
    Temlakos <temlakos@gmail.com>
    -- 
    fedora-list mailing list
    fedora-list@redhat.com
    To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
    

  • Next message: Trey Sizemore: "Conflicting yum repositories"

    Relevant Pages

    • Re: TCP port 5000 syn increasing
      ... I have noticed the TCP port 5000's also, and I'm getting a fair amount from ... > Security Linux, the comprehensive security solution that combines six ...
      (Incidents)
    • Re: Info on SMC Barricade
      ... 24.242.35.125:1025 to UDP port 137 ... Thursday, November 22, 2001 16:43:25 Unrecognized access from ... 213.131.184.204:2048 to TCP port 53 ...
      (Security-Basics)
    • RE: RDC Problem Driving me Mental
      ... SBS 2003 computer starts using TCP port 3389 before the Terminal Services ... The process that most frequently causes this problem is the Microsoft ... Exchange System Attendant service. ...
      (microsoft.public.windows.server.sbs)
    • Fedora 8 -- Install Failure For Test-WWW-Mechanize-Catalyst-0.41
      ... Fedora 8 i386 machine, it fails like this: ... # Starting an external Catalyst HTTP server on port 7357 ... # To change the port, please set the TWMC_TEST_PORT env variable. ... CPAN: File::HomeDir loaded ok ...
      (Fedora)
    • Re: Getting GPilot and J-Pilot to Play Nice In Fedora 7
      ... USB cable to sync with a Palm Treo 680. ... at all in Fedora 7. ... Palm devices use the first port to sync, ...
      (Fedora)