LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-13-2004, 08:30 AM   #1
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Rep: Reputation: 30
Help with Samba firewall


I've been tearing my hair out trying to get iptables to allow Samba traffic in. My Samba setup is fine, as if I stop iptables, everything works perfectly. From what I've read I need to allow TCP/UDP 137 and 139 in, but I can't work out how to enter it into the table.

I've been using the following, but none seem to work.

iptables -A INPUT -p udp --sport 139 -j ACCEPT (also for tcp and port 137)

also tried

iptables -A INPUT -p udp -s 192.168.0.0/24 - j ACCEPT

also tried

iptables -I INPUT -s 192.168.0.0/24 -p udp --dport 139 -j ACCEPT

but nothing seems to work. What I want is to allow anything on 192.168.0.* in through the Samba ports. Can anyone help?
 
Old 11-13-2004, 08:31 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Can you post the output from:
iptables -nL
 
Old 11-13-2004, 08:34 AM   #3
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
It might be a bit of a mess, but I've been playing for a few hours

Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Lokkit-0-50-INPUT all -- 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Lokkit-0-50-INPUT all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Lokkit-0-50-INPUT (2 references)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spts:67:68 dpts:67:68
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spts:67:68 dpts:67:68
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:0:1023 flags:0x16/0x02 reject-with icmp-port-unreachable
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:2049 flags:0x16/0x02 reject-with icmp-port-unreachable
REJECT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:0:1023 reject-with icmp-port-unreachable
REJECT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:2049 reject-with icmp-port-unreachable
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:6000:6009 flags:0x16/0x02 reject-with icmp-port-unreachable
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:7100 flags:0x16/0x02 reject-with icmp-port-unreachable
 
Old 11-13-2004, 09:16 AM   #4
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
I'm making some progress. As far as I can tell 137 and 139 are for file view/access. But some other port is being used for the secure login. I have one PC that was logged in with firewall down and now the firewall is up again it can still browse. However another PC that has not logged in before, is still getting a 'No service is operating' response.
 
Old 11-13-2004, 09:19 AM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If you are using lokkit then I suggest using it to add ports and not dealing with iptables directly, you just need custom ports:
137/UDP
138/UDP
139/TCP
 
Old 11-13-2004, 09:20 AM   #6
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
I would rather get to grips with the iptables, as I know that I'm going to need router functionality in the future. Any ideas about the login port?
 
Old 11-13-2004, 09:37 AM   #7
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
At the moment I'm using the following syntax, does this sound right?

iptables -A INPUT -s 192.168.0 -d 127.0.0.1 -p tcp --dport 137 -j ACCEPT
 
Old 11-13-2004, 09:40 AM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If you want to get to grips with iptables then scrap your lokkit rules and start from scratch with one of the many iptables tutorials out there, mixing them is just going to cause problems.

I'm not sure what you mean by a login port.
 
Old 11-13-2004, 09:44 AM   #9
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
As far as I can see lokkit isn't running. I try 'service lokkit stop' and it's not recognised. My iptables now look like below, but still no access for new PCs.

Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Lokkit-0-50-INPUT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 192.168.0.0 127.0.0.1 tcp dpt:137
ACCEPT udp -- 192.168.0.0 127.0.0.1 udp dpt:137
ACCEPT tcp -- 192.168.0.0 127.0.0.1 tcp dpt:139
ACCEPT udp -- 192.168.0.0 127.0.0.1 udp dpt:139
ACCEPT udp -- 192.168.0.0 127.0.0.1 udp dpt:443
ACCEPT tcp -- 192.168.0.0 127.0.0.1 tcp dpt:443
ACCEPT udp -- 192.168.0.0 127.0.0.1 udp dpt:138
ACCEPT tcp -- 192.168.0.0 127.0.0.1 tcp dpt:138

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Lokkit-0-50-INPUT all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Lokkit-0-50-INPUT (2 references)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spts:67:68 dpts:67:68
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spts:67:68 dpts:67:68
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:0:1023 flags:0x16/0x02 reject-with icmp-port-unreachable
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:2049 flags:0x16/0x02 reject-with icmp-port-unreachable
REJECT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:0:1023 reject-with icmp-port-unreachable
REJECT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:2049 reject-with icmp-port-unreachable
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:6000:6009 flags:0x16/0x02 reject-with icmp-port-unreachable
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:7100 flags:0x16/0x02 reject-with icmp-port-unreachable
 
Old 11-13-2004, 09:59 AM   #10
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
As far as I can see Lokkit is just a GUI for modifying your iptables. I only have the command line to work with, but surely it doesn't make any difference.
 
Old 11-13-2004, 10:18 AM   #11
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
lokkit is just a frontend for iptables but personally I htink they look complicated to work with manually. So I would either run "lokkit" and use it or scrap the rules that it has put in place "iptables -F". Then start with your own firewall which is customised for your needs/preferences.
 
Old 11-13-2004, 10:30 AM   #12
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
Thanks David, got it sorted at last. Just for anyone else reading this, I got around it as follows (this just gets Samba working):

iptables -F (clears out the current firewall rules)

iptables -A INPUT -s 192.168.0 -d 127.0.0.1 -p tcp --dport 137 -j ACCEPT
iptables -A INPUT -s 192.168.0 -d 127.0.0.1 -p tcp --dport 138 -j ACCEPT
iptables -A INPUT -s 192.168.0 -d 127.0.0.1 -p tcp --dport 139 -j ACCEPT

iptables -A INPUT -s 192.168.0 -d 127.0.0.1 -p udp --dport 137 -j ACCEPT
iptables -A INPUT -s 192.168.0 -d 127.0.0.1 -p udp --dport 138 -j ACCEPT
iptables -A INPUT -s 192.168.0 -d 127.0.0.1 -p udp --dport 139 -j ACCEPT

service iptables save (saves the rules to file)

You don't seem to need port 443 like everyone keeps saying. I've not got it open and it's working fine.

The above rules allow traffic on network address 192.168.0.* into the box on ports 137,138 and 139. You might not even need 138 open, but it's all netbios stuff, so I've done it anyway.

HTH
 
Old 11-13-2004, 10:37 AM   #13
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Just remember to add reject rules for things you don't want or use a default policy of drop and allow established and related connections in.
 
Old 11-14-2004, 01:51 AM   #14
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
I've been playing some more and the following is a more secure foolproof way of setting up a Samba firewall. Notice no port 138 or 443 as some places are saying. The following rules allow any traffic in on port 137 and 139 TCP and UDP:

iptables -F (clears out the current firewall rules)

iptables -P INPUT DROP (by default block all incoming traffic, all forwarded traffic, but allow anything out)
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

iptables -A INPUT -p tcp --dport 137 -j ACCEPT
iptables -A INPUT -p udp --dport 137 -j ACCEPT

iptables -A INPUT -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -p udp --dport 139 -j ACCEPT

service iptables save (saves the rules to file)
 
Old 11-14-2004, 02:36 PM   #15
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
You're confusing port 443/tcp (HTTPS) with port 445/tcp (MS Domain). In any case, I've never seen Samba use 445. It still uses the old NetBIOS ports.
 
  


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
Using firewall with samba Imanerd Linux - Networking 6 03-16-2005 04:25 PM
Samba Firewall Xaque208 Linux - Networking 2 12-29-2004 01:17 PM
samba + firewall palu Linux - Networking 2 06-13-2004 01:03 PM
RH9 SAMBA and Firewall jwspring Linux - Networking 17 12-10-2003 07:54 PM
How do I configure firewall for SAMBA? drwolfson Linux - Networking 4 11-05-2003 06:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:51 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