Operating System - HP-UX
1820906 Members
4640 Online
109629 Solutions
New Discussion юеВ

Re: Discover telnet client IP address

 
SOLVED
Go to solution

Discover telnet client IP address

I'd like to set the value of DISPLAY to be the client's IP address as opposed to the name returned by the DNS.
(Our DNS seems to be having some problems returning the correct name. When I issue who -um from a specific client PC it cycles through 3 different names and we're trying to get that issue sorted too)
Any suggestions greatly appreciated.
11 REPLIES 11
Steven E. Protter
Exalted Contributor

Re: Discover telnet client IP address

If the host is hpux, try this:

last -R

That will provide the hostname of the telnet and other protocol clients.

Also:
enhance your logging:
inetd -l

There will be information there mostly by ip address.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com

Re: Discover telnet client IP address

Forgot to mention platform: hp-ux 11.0

Tried the last command, but it too returns host names not ip addresses.

I read another thread where the contributor said that everything gets resolved back to the DNS name. Is there no way to avoid this and get the IP address (other than disabling DNS)?
Steven E. Protter
Exalted Contributor

Re: Discover telnet client IP address

Last command does turn up the hostnames.

These can be translated by reverse lookup to IP addresses with the nslookup command. See the man for that one.

Also, the times on the last command will correspond to data in the syslog which will be exclusively IP addresses.

Yes, you may actually have to do a little work to get the information, but your system records all you need to do the job.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Muthukumar_5
Honored Contributor

Re: Discover telnet client IP address

Your problem is because of your hostname being displayed on who -um command output.
We can get reverse lookup of ip-address with getip / nslookup / nsquery / dig command.

I prefer getip command for this.

export DISPLAY=getip `who -um | awk '{ print $9 }'`.0

HTH.
Easy to suggest when don't know about the problem!
Vishwas Pai
Regular Advisor

Re: Discover telnet client IP address


As the initial post said, they have some
problem with DNS and hence he wants to use
only ip@.

My question is will getip again contact
DNS for get the ip@ of the hostname ?

-vishwas
Ralph Grothe
Honored Contributor

Re: Discover telnet client IP address

As it looks the getip is a simple wrap of the gethostbyname() syscall.
In the syscall's manpage it says that it will respect the hosts entry in /etc/nsswitch.conf.
So if his nsswitch.conf holds something like:

hosts: files [NOTFOUND=continue] dns

it will do namelookup by first parsing /etc/hosts on the localhost, where it should find the IP address.

Alternatively you could use nsquery like

DISPLAY=$(nsquery hosts $(who -mu|awk '{print$NF}')|awk '$1~/ddress/{print$NF}'):0
Madness, thy name is system administration
Ivajlo Yanakiev
Respected Contributor

Re: Discover telnet client IP address

Hi,

If you have problems whit your DNS you must corect them. HPUX work fine olny if DNS is ok. Telnet,sam,X and Software agent need
ip resolve.
If you have problem with DNS use /etc/hosts file.
File that is good to check.

/etc/nsswitch.conf
/etc/resolve.conf
/etc/hosts


if you can not find /etc/nsswitch.conf
copy /etc/nsswitch.files /etc/nsswitch.conf



Re: Discover telnet client IP address

Thanks for all your replies. We've deep clensed the DNS now and aged out all the duff records.

Just one point, I changed the inetd configuation (netdaemons) to start inetd with the -l option then executed inetd -c but still do not see detailed loging in syslog. Do I need to do a reboot to enable the change?
Ivajlo Yanakiev
Respected Contributor

Re: Discover telnet client IP address

Do not reboot.
Only windows need reboot :) you now :)
if you need to restart some services go to
/sbin/init.d/
and

./someservices stop
./someservices start

Dietmar Konermann
Honored Contributor
Solution

Re: Discover telnet client IP address

Michael,

in Windows reboot - on Unix be root. ;-)

Simpy issue "inetd -l" to toggle logging on/off. You see the effect immediately in syslog.log.

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)

Re: Discover telnet client IP address

Thanks all