LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-26-2007, 10:50 AM   #1
landev
Member
 
Registered: Aug 2006
Posts: 43

Rep: Reputation: 15
Hosts.allow... Can't verify hostname.


Greetings,

I'm having problems with a user trying to ssh to one of my servers from his home DSL. As the ISP seems to assign random addresses to the user, I have added the line:

sshd : .verizon.net : allow

to the hosts.allow file to (I assumed) allow all connections from that domain. The user can connect sometimes, but not others (which I find most curious!) An example of a disallowed connection in my messages file is:

warning: /etc/hosts.allow, line 7: can't verify hostname: getaddrinfo(pool-68-238-143-94.sea.dsl-w.verizon.net, AF_INET) failed

So... why can the user connect sometimes, but not others from the verizon.net domain? Obviously DNS can't resolve the above address, but shouldn't the ".verizon.net" domain specification in the hosts.allow file allow for any connection from that domain?

I thought about using the AllowUsers variable in the sshd_config file, but that seems to me to be opening the machine up for more mischief.

Suggestions...?

Thanks in advance!

-l-
 
Old 11-26-2007, 12:00 PM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
From the tcpd man page:

Quote:
HOST NAME VERIFICATION
The authentication scheme of some protocols (rlogin, rsh) relies on
host names. Some implementations believe the host name that they get
from any random name server; other implementations are more careful but
use a flawed algorithm.

tcpd verifies the client host name that is returned by the
address->name DNS server by looking at the host name and address that
are returned by the name->address DNS server. If any discrepancy is
detected, tcpd concludes that it is dealing with a host that pretends
to have someone elses host name.

If the sources are compiled with -DPARANOID, tcpd will drop the connec-
tion in case of a host name/address mismatch. Otherwise, the hostname
can be matched with the PARANOID wildcard, after which suitable action
can be taken.
For some reason, the nslookup for the name doesn't match the nslookup for the ip or it is timing out.

HTH

Forrest
 
Old 11-27-2007, 01:54 PM   #3
landev
Member
 
Registered: Aug 2006
Posts: 43

Original Poster
Rep: Reputation: 15
I spoke to another sysad about this and he said that the problem with with ISPs gaining blocks of addresses that are not registered with DNS. He suggested to get around my problem using iptables instead and tie to the MAC rather than the domain. I'll take a whack at it from that avenue.

Thanks,

-l-
 
Old 11-27-2007, 02:06 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by landev View Post
He suggested to get around my problem using iptables instead and tie to the MAC rather than the domain.
MAC addresses don't get routed, hence they don't work on the Internet. They work with data link layer protocols, unlike IP (Internet Protocol) which works with the network layer. Using AllowUsers along with Fail2Ban (or something similar) would seem like a perfectly acceptable setup IMHO.

Last edited by win32sux; 11-27-2007 at 02:09 PM.
 
Old 11-27-2007, 02:44 PM   #5
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Exactly how random are the IP addresses? I'm guessing that they are probably fairly close in range. Adding:

sshd : 68.238.143. : allow

to your hosts.allow file would probably work for any IP your user would get as they are still going to access the same switch even if it assigns them a different IP. Look at your logs and see what IP's have been assigned in the past.

Or is this multiple users?

To open up the list to about a thousand possible hosts around the same IP use:

sshd : 68.238.140.1/255.255.252.0 : allow


HTH

Forrest
 
Old 11-28-2007, 03:23 PM   #6
landev
Member
 
Registered: Aug 2006
Posts: 43

Original Poster
Rep: Reputation: 15
In running wireshark on the server, I noticed that the IP addresses were wildly different (i.e. 131.191.xxx.xx to 65.46.xxx.xxx) from the same mac. What was curious is that the mac didn't coincide with the end user's mac, the mac of her airport, nor the mac of her cablemodem. Not sure where the true connection point is, but iptables turned out the way to go in letting the user in. I set DROP as the default rule and added the line:

-A RH-Firewall-1-INPUT -p tcp --destination-port 22 -m mac --mac-source 00:1A:A6:CA:B7:10 -j ACCEPT


The servers now let in that machine without a hitch and drop other (uninvited) clients. What's really nice is that outside attackers now get no reply from the servers as their packets are dropped rather than rejected (as they were using hosts.allow.)

Thanks All!

-l-
 
Old 11-28-2007, 05:48 PM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by landev View Post
In running wireshark on the server, I noticed that the IP addresses were wildly different (i.e. 131.191.xxx.xx to 65.46.xxx.xxx) from the same mac. What was curious is that the mac didn't coincide with the end user's mac, the mac of her airport, nor the mac of her cablemodem.
Yes, as has been explained, MACs don't get routed (without special tools). It's not curious, it's expected.

What would be curious (perhaps even strange/weird) is if they did match.

Quote:
Not sure where the true connection point is, but iptables turned out the way to go in letting the user in. I set DROP as the default rule and added the line:

-A RH-Firewall-1-INPUT -p tcp --destination-port 22 -m mac --mac-source 00:1A:A6:CA:B7:10 -j ACCEPT

The servers now let in that machine without a hitch and drop other (uninvited) clients. What's really nice is that outside attackers now get no reply from the servers as their packets are dropped rather than rejected (as they were using hosts.allow.)
If this is indeed an Internet setup, then your rule is bogus. Most likely it's the MAC of your router's LAN interface (it's definitely something on your LAN). Thus, the MAC match in the rule would be pointless, as it would be the same MAC which would show-up for anyone hitting that SSH daemon (or anything else on your box for that matter, when accessed via the WAN/Internet). When you look at iptables INPUT logs, the "MAC=" field's first six segments are the MAC of the interface the packet came into. The next six segments are the MAC of the LAN point which sent you the packet. With packets coming into your box from the Internet, these will always be the same (unless your router/modem is changed or whatever) - regardless of the source IP. Once again, just to be clear: MAC address filtering does not apply to packets coming from the Internet.

Last edited by win32sux; 11-28-2007 at 06:15 PM.
 
Old 11-28-2007, 07:59 PM   #8
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Here is the hardware vendor assigned to that mac address if it helps determine what it is:

00-1A-A6 (hex) Telefunken Radio Communication Systems GmbH &CO.KG
001AA6 (base 16) Telefunken Radio Communication Systems GmbH &CO.KG
Eberhard-Finckh-Strasse 55
Ulm Baden-Württemberg 89075
GERMANY

Also, win32sux, where did you get this info about the MAC info, I'd never heard that. I just figured that the mac was the mac of whatever router/switch the server was plugged into.

HTH

Forrest
 
Old 11-29-2007, 12:16 PM   #9
landev
Member
 
Registered: Aug 2006
Posts: 43

Original Poster
Rep: Reputation: 15
"MAC address filtering does not apply to packets coming from the Internet."

Whelp, I can't argue with that! I feel a bit like Don Quioxote... I thought that cool trick worked... it was, indeed, the router's address (as I found when I still saw hoards of traffic coming through after my "magic fix".) 'Guess I should pay more attention to the bright folks here than to my local "expert" sources!

I'll take a whack at using the fail2ban solution and report back!

Thanks!

-l-
 
Old 11-29-2007, 01:29 PM   #10
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
You have also put back into play the hosts.allow solution as the IP addresses you were seeing can now be known to be from any host that was attempting to contact your server, not just your users.
 
  


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
/etc/hosts, hostname, and dnsdomainname questions rdmenotte Linux - Software 9 03-28-2015 04:27 AM
hostname, fqdn, /etc/hosts setup [GOD]Anck Slackware 9 07-20-2010 04:51 PM
Changing Hostname.../etc/hosts...? vous Linux - Networking 13 01-16-2008 08:38 PM
Problem with hostname and /etc/hosts file toxikco2 Debian 6 03-07-2007 08:55 PM
/etc/hosts.allow can't verify allowed hostname - what do I do? Dragons Master Linux - Security 3 05-05-2006 06:05 AM

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

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