Skip to contentSkip to conversation

Samba Blocked? (repost)

DISCUSSION Dan Egli 3 participants 6 messages Nov 26, 2002 – Nov 27, 2002

lore
Share & tools
lore

Dan Egli

author
#0 lore raw

Ok. I'm a fair bit confused here. I'm trying to setup a IPtables filter set that will block certain ports and allow others. It seems to work perfectly for anything other than Samba. If I try:

smbclient //myserver/shared1, it fails to connect. But using the IP in place of it:
smbclient //192.168.0.2/shared1 works just fine. I am specifically allowing NetBIOS-ns, NetBIOS-ssn, and NetBIOS-dgm. Still no go. What's wrong?

Thanks!
-- Dan

tables:

#!/bin/bash
IPT=/sbin/iptables

# step 1 - ensure iptables are loaded
modprobe ip_conntrack_ftp
# that should pull in all dependant modules
#step 2  SET DEFAULT POLICY

$IPT -P INPUT DROP
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD DROP

# step 3 FLUSH THE TABLES
$IPT -F INPUT
$IPT -F OUTPUT
$IPT -F FORWARD
$IPT -t nat -F PREROUTING
$IPT -t nat -F POSTROUTING
$IPT -t nat -F OUTPUT
# setp 4 - setup rules
$IPT -A INPUT -p tcp -m multiport --dports smtp,ftp,telnet,ssh -j ACCEPT
$IPT -A INPUT -p tcp -i eth0 -m multiport --dports
telnet,ssh,domain,nntp,ntp,printer,pop3,imap,http,https,netbios-ns,netbios-d
gm,netbios-ssn -j ACCEPT
$IPT -A INPUT -p udp -i eth0 -m multiport --dports
domain,ntp,netbios-ns,netbios-dgm,netbios-ssn -j ACCEPT
$IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -j LOG

$IPT -A FORWARD -i eth0 -j ACCEPT
$IPT -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT $IPT -A FORWARD -j LOG

# step 5 - enable NAT
$IPT -t nat -A POSTROUTING -o eth1 -j SNAT --to-source 64.122.31.38
# step 6 - setup the proc files for a propper firewall

echo 1 > /proc/sys/net/ipv4/ip_forward

P.S. With these rules, it should only log packets that are failing, and I see the packets on port 137 in the log, so I don't know what's wrong.

#1 lore raw
Quoted 19 lines · Dan Egli

Ok. I'm a fair bit confused here. I'm trying to setup a IPtables filter set that will block certain ports and allow others. It seems to work perfectly for anything other than Samba. If I try:

smbclient //myserver/shared1, it fails to connect. But using the IP in place of it:
smbclient //192.168.0.2/shared1 works just fine. I am specifically allowing NetBIOS-ns, NetBIOS-ssn, and NetBIOS-dgm. Still no go. What's wrong?

# setp 4 - setup rules
$IPT -A INPUT -p tcp -m multiport --dports smtp,ftp,telnet,ssh -j ACCEPT
$IPT -A INPUT -p tcp -i eth0 -m multiport --dports
telnet,ssh,domain,nntp,ntp,printer,pop3,imap,http,https,netbios-ns,netbios-
d gm,netbios-ssn -j ACCEPT
$IPT -A INPUT -p udp -i eth0 -m multiport --dports
domain,ntp,netbios-ns,netbios-dgm,netbios-ssn -j ACCEPT
$IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -j LOG
Quoted 2 lines

P.S. With these rules, it should only log packets that are failing, and I see the packets on port 137 in the log, so I don't know what's wrong.

Have you tried replacing netbios-ns with 137 in the rules? It may not be resolving the name properly through your /etc/services file. I don't see any other reason they should reach the log rule.

If that isn't it, maybe you can post a few of the droplog lines for 137s? Also, I assume you are seeing 137 logged only when connection fails?

j

author
#2 lore raw

that is correct. And I know for a fact that NetBIOS-ns is in the services file because I've seen it, and I did try it both ways. Every time I try to connect using //myserver/shared1 I get the following log lines:

Nov 26 20:22:11 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=64.122.31.38
DST=64.122.31.38 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:22:11 mail last message repeated 2 times
Nov 26 20:22:28 mail kernel: IN=eth1 OUT=
MAC=00:80:ad:c8:b0:a9:00:00:c5:81:21:44:08:00 SRC=63.241.23.201
DST=64.122.31.38 LEN=64 TOS=0x00 PREC=0x00 TTL=48 ID=29779 PROTO=ICMP TYPE=8
CODE=0 ID=45290 SEQ=0
Nov 26 20:22:29 mail kernel: IN=eth1 OUT=
MAC=00:80:ad:c8:b0:a9:00:00:c5:81:21:44:08:00 SRC=63.241.23.201
DST=64.122.31.38 LEN=64 TOS=0x00 PREC=0x00 TTL=48 ID=29782 PROTO=ICMP TYPE=8
CODE=0 ID=45290 SEQ=256
Nov 26 20:22:30 mail kernel: IN=eth1 OUT=
MAC=00:80:ad:c8:b0:a9:00:00:c5:81:21:44:08:00 SRC=63.241.23.201
DST=64.122.31.38 LEN=64 TOS=0x00 PREC=0x00 TTL=48 ID=29792 PROTO=ICMP TYPE=8
CODE=0 ID=45290 SEQ=512
Nov 26 20:22:37 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1
LEN=78 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=32807 DPT=137 LEN=58
Nov 26 20:22:42 mail last message repeated 2 times
Nov 26 20:22:44 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=192.168.0.2
DST=192.168.0.2 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:22:44 mail last message repeated 2 times
Nov 26 20:22:44 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=64.122.31.38
DST=64.122.31.38 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:22:45 mail last message repeated 2 times
Nov 26 20:23:05 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1
LEN=78 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=32807 DPT=137 LEN=58
Nov 26 20:23:09 mail last message repeated 2 times
Nov 26 20:23:11 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=192.168.0.2
DST=192.168.0.2 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:23:12 mail last message repeated 2 times
Nov 26 20:23:12 mail kernel: IN=lo OUT=

MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=64.122.31.38 DST=64.122.31.38 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137 DPT=32807 LEN=70

and myserver is in my /etc/hosts as 192.168.0.2 (correct IP).

Help?

-- Dan

----- Original Message -----
From: "Joel Newkirk" <[email protected]>
To: "Dan Egli" <[email protected]>;
<[email protected]>
Sent: Tuesday, November 26, 2002 5:24 PM
Subject: Re: Samba Blocked? (repost)

Quoted 1 line · Dan Egli

Ok. I'm a fair bit confused here. I'm trying to setup a IPtables filter

set

Quoted 6 lines

that will block certain ports and allow others. It seems to work perfectly for anything other than Samba. If I try:

smbclient //myserver/shared1, it fails to connect. But using the IP in place of it:
smbclient //192.168.0.2/shared1 works just fine. I am specifically

allowing

Quoted 6 lines

NetBIOS-ns, NetBIOS-ssn, and NetBIOS-dgm. Still no go. What's wrong?

# setp 4 - setup rules
$IPT -A INPUT -p tcp -m multiport --dports smtp,ftp,telnet,ssh -j ACCEPT
$IPT -A INPUT -p tcp -i eth0 -m multiport --dports

telnet,ssh,domain,nntp,ntp,printer,pop3,imap,http,https,netbios-ns,netbios-

Quoted 8 lines

d gm,netbios-ssn -j ACCEPT
$IPT -A INPUT -p udp -i eth0 -m multiport --dports domain,ntp,netbios-ns,netbios-dgm,netbios-ssn -j ACCEPT $IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT $IPT -A INPUT -j LOG

P.S. With these rules, it should only log packets that are failing, and I see the packets on port 137 in the log, so I don't know what's wrong.

Have you tried replacing netbios-ns with 137 in the rules? It may not be resolving the name properly through your /etc/services file. I don't see any
other reason they should reach the log rule.

If that isn't it, maybe you can post a few of the droplog lines for 137s? Also, I assume you are seeing 137 logged only when connection fails?

j

#3 lore raw
Quoted 3 lines · Dan Egli

that is correct. And I know for a fact that NetBIOS-ns is in the services file because I've seen it, and I did try it both ways. Every time I try to connect using //myserver/shared1 I get the following log lines:

Very strange. the only packets caught here with --dport 137 are on lo with lo IP, then --sport 137 with 64.x.x.x on lo, and --sport 137 with local 192.x x.x on lo. It looks like the 'real' --dport 137 packets get through (they're not listed here) but the machine tries to query itself on lo to resolve the names. shot in the dark, try:

/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT

to let these through. I've only done minimal work with samba, so I don't know if this self-request is normal or not...

j

Quoted 102 lines
Nov 26 20:22:11 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=64.122.31.38
DST=64.122.31.38 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:22:11 mail last message repeated 2 times
Nov 26 20:22:28 mail kernel: IN=eth1 OUT=
MAC=00:80:ad:c8:b0:a9:00:00:c5:81:21:44:08:00 SRC=63.241.23.201
DST=64.122.31.38 LEN=64 TOS=0x00 PREC=0x00 TTL=48 ID=29779 PROTO=ICMP
TYPE=8 CODE=0 ID=45290 SEQ=0
Nov 26 20:22:29 mail kernel: IN=eth1 OUT=
MAC=00:80:ad:c8:b0:a9:00:00:c5:81:21:44:08:00 SRC=63.241.23.201
DST=64.122.31.38 LEN=64 TOS=0x00 PREC=0x00 TTL=48 ID=29782 PROTO=ICMP
TYPE=8 CODE=0 ID=45290 SEQ=256
Nov 26 20:22:30 mail kernel: IN=eth1 OUT=
MAC=00:80:ad:c8:b0:a9:00:00:c5:81:21:44:08:00 SRC=63.241.23.201
DST=64.122.31.38 LEN=64 TOS=0x00 PREC=0x00 TTL=48 ID=29792 PROTO=ICMP
TYPE=8 CODE=0 ID=45290 SEQ=512
Nov 26 20:22:37 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1
LEN=78 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=32807 DPT=137 LEN=58
Nov 26 20:22:42 mail last message repeated 2 times
Nov 26 20:22:44 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=192.168.0.2
DST=192.168.0.2 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:22:44 mail last message repeated 2 times
Nov 26 20:22:44 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=64.122.31.38
DST=64.122.31.38 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:22:45 mail last message repeated 2 times
Nov 26 20:23:05 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1
LEN=78 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=32807 DPT=137 LEN=58
Nov 26 20:23:09 mail last message repeated 2 times
Nov 26 20:23:11 mail kernel: IN=lo OUT=
MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=192.168.0.2
DST=192.168.0.2 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137
DPT=32807 LEN=70
Nov 26 20:23:12 mail last message repeated 2 times
Nov 26 20:23:12 mail kernel: IN=lo OUT=

MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=64.122.31.38 DST=64.122.31.38 LEN=90 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=137 DPT=32807 LEN=70

and myserver is in my /etc/hosts as 192.168.0.2 (correct IP).

Help?

-- Dan

----- Original Message -----
From: "Joel Newkirk" <[email protected]>
To: "Dan Egli" <[email protected]>;
<[email protected]>
Sent: Tuesday, November 26, 2002 5:24 PM
Subject: Re: Samba Blocked? (repost)

Quoted 1 line · Dan Egli

Ok. I'm a fair bit confused here. I'm trying to setup a IPtables filter

set

Quoted 6 lines

that will block certain ports and allow others. It seems to work perfectly for anything other than Samba. If I try:

smbclient //myserver/shared1, it fails to connect. But using the IP in place of it:
smbclient //192.168.0.2/shared1 works just fine. I am specifically

allowing

Quoted 5 lines

NetBIOS-ns, NetBIOS-ssn, and NetBIOS-dgm. Still no go. What's wrong?

# setp 4 - setup rules
$IPT -A INPUT -p tcp -m multiport --dports smtp,ftp,telnet,ssh -j ACCEPT
$IPT -A INPUT -p tcp -i eth0 -m multiport --dports

telnet,ssh,domain,nntp,ntp,printer,pop3,imap,http,https,netbios-ns,netbios-

Quoted 8 lines

d gm,netbios-ssn -j ACCEPT
$IPT -A INPUT -p udp -i eth0 -m multiport --dports domain,ntp,netbios-ns,netbios-dgm,netbios-ssn -j ACCEPT $IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT $IPT -A INPUT -j LOG

P.S. With these rules, it should only log packets that are failing, and I see the packets on port 137 in the log, so I don't know what's wrong.

Have you tried replacing netbios-ns with 137 in the rules? It may not be resolving the name properly through your /etc/services file. I don't see any
other reason they should reach the log rule.

If that isn't it, maybe you can post a few of the droplog lines for 137s? Also, I assume you are seeing 137 logged only when connection fails?

j

#4 lore raw
Quoted 14 lines · Joel Newkirk
Quoted 5 lines · Dan Egli

that is correct. And I know for a fact that NetBIOS-ns is in the services file because I've seen it, and I did try it both ways. Every time I try to connect using //myserver/shared1 I get the following log lines:

Very strange. the only packets caught here with --dport 137 are on lo with lo IP, then --sport 137 with 64.x.x.x on lo, and --sport 137 with local 192.x x.x on lo. It looks like the 'real' --dport 137 packets get through (they're not listed here) but the machine tries to query itself on lo to resolve the names. shot in the dark, try:

Quoted 7 lines

/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT

to let these through. I've only done minimal work with samba, so I don't know if this self-request is normal or not...

I think it's due to smbd talking to nmbd via lo when it receives a bcast ?? Something like that. Something like this is generally needed anyway:

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

Cheers,
Michael

author
#5 lore raw

I will try this one then. Thanks!
----- Original Message -----
From: "Michael" <[email protected]>
To: <[email protected]>
Sent: Wednesday, November 27, 2002 1:06 AM
Subject: Re: Samba Blocked? (repost)

Quoted 6 lines
Quoted 4 lines · Joel Newkirk
Quoted 1 line · Dan Egli

that is correct. And I know for a fact that NetBIOS-ns is in the

services

Quoted 1 line
Quoted 1 line
Quoted 1 line

file because I've seen it, and I did try it both ways. Every time I try

to

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

connect using //myserver/shared1 I get the following log lines:

Very strange. the only packets caught here with --dport 137 are on lo

with lo IP, then

Quoted 1 line
Quoted 1 line

--sport 137 with 64.x.x.x on lo, and --sport 137 with local 192.x x.x on

lo. It looks like the

Quoted 1 line
Quoted 1 line

'real' --dport 137 packets get through (they're not listed here) but the

machine tries to

Quoted 6 lines
Quoted 6 lines

query itself on lo to resolve the names. shot in the dark, try:

/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT

to let these through. I've only done minimal work with samba, so I don't

know if this self-request

Quoted 18 lines
Quoted 3 lines

is normal or not...

I think it's due to smbd talking to nmbd via lo when it receives a bcast ?? Something like that.
Something like this is generally needed anyway:

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

Cheers,
Michael