I have ALL: ALL in hosts.allow. Should I remove that?
Main Topics
Browse All TopicsI want to restrict samba access to a linux host from windows hosts. I've put the following in my /etc/hosts.deny:
smbd: ALL
but it still permits connection. What am I doing wrong?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you remove the line from hosts.allow, what will happen is that what you configure in hosts.deny will be denied. I think that this is the behavior you expect!
If tcpwrappers cannot find any rule for a certain packet in the two configuration files, it grants permission to the connection. You will not block anything more than what is configured in hosts.deny by doing this.
I've removed the ALL:ALL from hosts.allow, but it is still getting through. I'm starting smbd from /etc/rc.samba, not via inetd services, so maybe that's why hosts.deny is no working. What do you think?
In fact, I ultimately want to permit the local hosts, but deny attempts by hackers. I'm just testing with local hosts. I currently have 179 different outside IPs that are trying to access this system via samba. I don't want to enter all these computers into a block list. smbd is denying access just fine, but I'd rather not let them through that far in the first place (it certainly creates a lot of files in /var/log!)
With respect to firewall, I'm nore sure what port samba uses! In fact, I'm not sure how these folks are even getting to smbd in the first place because I only have a few ports enabled in the firewall.
Is there some other way to achieve what I want?
I currently have 179 different outside IPs that are trying to access this system via samba. ::
Is this samba server is also a public server ?? Samba runs on port 139 for tcp, udp/137/138
if you can telnet your server to port 139 from Outside of your network that means your server is wide open to outside
can you try to tellnet to samba from outside of your network ??
telnet public-ip 139
see if it connects
or from inside network from any pc go to this website
http://www.canyouseeme.org
and scan, it will tell you what ports are open
Whoa... if your file server is available to the Internet, then it shouldn't be allowing samba out on the Internet interface at all. Use the interfaces option in your smb.conf file to keep samba from talking on the Internet facing network at all!
Assuming your Internet-facing network card is eth0 and your LAN-facing network card is eth1, you would make the following entry in /etc/samba/smb.conf (or wherever your distribution put the smb.conf file):
--- begin section of smb.conf ---
[global]
interfaces = eth1 lo
bind interfaces only = yes
--- end section of smb.conf ---
You allow the lo interface for loopback (useful in testing samba), and obviously the eth1 interface for your local hosts.
You can also accomplish this with firewall rules, or about 100 other ways (typical *nix systems!)... but this is the easiest & most robust method... IMHO!
Good luck!
Dan
IT4SOHO
PS: If you've got only one interface, then you'll have to use either iptables, or a "hosts allow" in your smb.conf... To specifically allow only specific hosts (IP addresses), use something like this:
--- begin section of smb.conf ---
[global]
hosts allow = 127.0.0.1 192.168.0.0/24
--- end section of smb.conf ---
This will allow only the specified hosts (localhost = 127.0.0.1, and I assumed your LAN would be 192.168.0.0/255.255.255.0)
Finally, since Windows 2000 there has been a "preferred" windows file sharing port of 445... ports 137-139 date from Windows 3.1 & Windows NT and are supported even today up through Windows 7, but Samba & all modern Windows clients will TRY on TCP port 445 first!
Whew....
Dan
Well folks, fosiul01 got me to thinking. I tried the telnet public-ip 139
and, no, I cannot get to the host. So, I looked more closely at my 179 files (named: samba.xx.xx.xx.xx where x' are the IP of the offender), and all appear to be dated from earlier this year, before I had the firewall up. During that time samba was denying access. Typical contents of one of these files:
[2009/01/09 11:37:14, 0] lib/access.c:check_access(
Denied connection from (64.147.31.118)
[2009/01/09 11:37:14, 1] smbd/process.c:process_smb
Connection denied from 64.147.31.118
My smb.conf has: hosts allow = 192.168.0. 127., more or less per it4soho's comment, so I don't think we were in DANGER.
I guess I should have looked more carefully at the timestamp on these log files before calling for help. Good info, anyway!
Business Accounts
Answer for Membership
by: RBEIMSPosted on 2009-08-13 at 14:03:55ID: 25092994
How is configured your hosts.allow?
hosts.allow takes precedence over hosts.deny
If there is a rule accepting the connection there, the hosts.deny file will not be processed.