LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-12-2012, 08:52 PM   #1
sljunkie
Member
 
Registered: Nov 2008
Location: Brazil
Distribution: Manjaro
Posts: 105

Rep: Reputation: 18
Samba + iptables issue


Hi,

My iptables configuration is based upon Arch Linux's Simple Stateful Firewall solution. However, Samba doesn't work with it, even though I order the 137/UDP, 138/UDP, 139/TCP and 445/TCP ports to be open! Here's my configuration:

Code:
# Generated by iptables-save v1.4.16.2 on Mon Nov 12 23:02:57 2012
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:TCP - [0:0]
:UDP - [0:0]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate INVALID -j DROP
-A INPUT -p icmp -m icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -p udp -m conntrack --ctstate NEW -j UDP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j TCP
-A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p tcp -j REJECT --reject-with tcp-reset
-A INPUT -j REJECT --reject-with icmp-proto-unreachable
-A TCP -s 192.168.0.0/24 -p tcp -m tcp --dport 22 -j ACCEPT
-A TCP -s 192.168.0.0/24 -p tcp -m tcp --dport 631 -j ACCEPT
-A TCP -s 192.168.0.0/24 -p tcp -m tcp --dport 139 -j ACCEPT
-A TCP -s 192.168.0.0/24 -p tcp -m tcp --dport 445 -j ACCEPT
-A TCP -s 192.168.0.0/24 -p tcp -m tcp --dport 2049 -j ACCEPT
-A UDP -s 192.168.0.0/24 -p udp -m udp --dport 137 -j ACCEPT
-A UDP -s 192.168.0.0/24 -p udp -m udp --dport 138 -j ACCEPT
-A UDP -s 192.168.0.0/24 -p udp -m udp --dport 5353 -j ACCEPT
COMMIT
Everything covered by the rules I open with iptables -A TCP/UDP -p tcp/udp --dport DPORT works...

With the firewall enabled, smbtree (and nautilus navigation) returns nothing... and smbclient SERVER/Sharename returns with (Error NT_STATUS_BAD_NETWORK_NAME)...

Last edited by sljunkie; 12-13-2012 at 03:06 PM.
 
Old 12-13-2012, 02:19 AM   #2
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi,

If you can afford (clear security risk) is your Samba configuration works with the FW off?
 
Old 12-13-2012, 02:21 AM   #3
sljunkie
Member
 
Registered: Nov 2008
Location: Brazil
Distribution: Manjaro
Posts: 105

Original Poster
Rep: Reputation: 18
Yes, with the firewall off Samba works, but no, I can't afford that, even in a small and stupid LAN a package filter is necessary.
 
Old 12-13-2012, 05:19 AM   #4
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
I think ports 137 and 138 should also be for tcp as well
 
Old 12-13-2012, 03:03 PM   #5
sljunkie
Member
 
Registered: Nov 2008
Location: Brazil
Distribution: Manjaro
Posts: 105

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by fotoguy View Post
I think ports 137 and 138 should also be for tcp as well
I opened them and nothing happened... well the Samba documentation says these ports are for udp.
 
Old 12-13-2012, 03:46 PM   #6
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
This is what I have in my firewall script for Samba
Code:
## Samba
# Samba uses UDP on ports 137 & 138 for nmbd and
# Samba uses TCP on ports 139 & 445 for smbd
# Accept the UDP packets so that they are not logged
$IPTABLES -A INPUT -i $EXTIF -s $LOCAL_LAN -p udp --sport 137 -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -s $LOCAL_LAN -p udp --dport 137 -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -s $LOCAL_LAN -p udp --dport 138 -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -s $LOCAL_LAN -p tcp --dport 139 -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -s $LOCAL_LAN -p tcp --dport 445 -j ACCEPT
I am not familiar with the Arch Linux Simple Stateful Firewall solution, so I do not know how the TCP and UDP chains are used.
Have you tried changing these to the INPUT chain?
 
2 members found this post helpful.
Old 12-13-2012, 04:10 PM   #7
sljunkie
Member
 
Registered: Nov 2008
Location: Brazil
Distribution: Manjaro
Posts: 105

Original Poster
Rep: Reputation: 18
Thumbs up

Code:
$IPTABLES -A INPUT -i $EXTIF -s $LOCAL_LAN -p udp --sport 137 -j ACCEPT
THANK YOU

That was the missing rule, the *source port* for nmbd calls... it's working now, THANKS!

I guess I'll post that in the wiki and/or warn the Samba documentation folks, because when we hear 'open up port x' we associate immediatly with a --dport type of rule.
 
  


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
samba file permission & build_sam_account issue in samba cnt Linux - Server 5 08-10-2011 01:19 PM
Samba issue (SAMBA and OpenLDAP for PDC) nyu2009 Linux - Server 1 08-01-2009 11:00 AM
Iptables Issue satish Linux - Networking 1 02-04-2009 04:51 AM
iptables samba issue shio Linux - Networking 1 07-12-2007 10:10 PM
iptables issue rkemp Linux - Networking 3 11-29-2003 06:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:28 PM.

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