Linux Port Listen port 43, local whois server

Hi,

I configure my linux to receive whois requests.
What I want is,
when a user did
"whois such-a-domain.com@whois.my-domain.com"
This script should be return the value after whois, namely
"such-a-domain.com@whois.my-domain.com".
To do this, I think I need to listen the whois port 43.

Anybody have/know? a C program which returns this...

Waiting for your answers...
LVL 1
EgeAsked:
Who is Participating?
 
bkdcConnect With a Mentor Commented:
Oh, one more thing. I'm not very familiar with Linux (I guess that's what you're using) cause I use QNX which is slightly different but I think that you should make some changes in xinetd.d/whois or whatever.

filename: xinetd.d/whois
service whois
{
       disable         = no
       socket_type     = stream
       wait            = no
       user            = root
       server          = /usr/sbin/in.ege.whoisd
}

That way inetd will call your program instead of the default in.whoisd
0
 
bkdcCommented:
there were tons of questions on socket programming so, please, be more specific.
 What do you need ? a tutorial on sockets,TCP/IP, etc ?
0
 
EgeAuthor Commented:
Hi again,
I need the following.
As everybody know, there exists a WHOIS SERVER (not client)

I configure my linux to accept whois requests via the port 43 (default whois port in RedHat).

With this configuration, if a whois request received, linux system runs the code /usr/sbin/in.whoisd
I will put my own executable instead of default one.

I want a C/C++ program to put this in.whoisd executable, such that, it understands the request.

Sample request:
whois subdomain.mydomain.com@whois.mydomain.com

whois.mydomain.com is my machine of course, and

subdomain.mydomain.com is a sub domain of my domain[s].

What I want is understanding the left part of @
(means subdomain.mydomain.com).

Such that, I can process my SQL queries and print the result...

In fact, the function not realy required to be a C code, it can also be a shell script or some other. But I prefer C.

Thanx for your interest...
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
bkdcCommented:
>>What I want is understanding the left part of @
(means subdomain.mydomain.com).

What do you want to understand ?
You mean you need help parsing the "whois subdomain.mydomain.com@whois.mydomain.com" stuff (read string) ?
 Is this what you want:
1. parse the string
2. get the subdomain string
3. search for it somethere
4. return stuff ?
0
 
EgeAuthor Commented:
Yes.
Absolutuley yes.

Details:

filename: xinetd.d/whois
service whois
{
        disable         = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.whoisd
}

And system calls
/usr/sbin/in.whoisd in time a request accepted.

I want to get the string whois subdom@whois.mydom.com

Rest is easy!

I tried with PERL and C using the SOCKET programming.

I got "address already in use" !

have any utility, which gets that string into a variable?

best regards...

0
 
bkdcCommented:
First of all, I strongly advise you to take a look (a closer look) at the following address:

http://community.roxen.com/developers/idocs/rfc/rfc1714.html

>>I got "address already in use" !

 Whois service is (usually) running on port 43. Since that port is already taken by the default /usr/sbin/in.whoisd
it's normal not to be able to establish a listening socket on that port. In fact, the port is taken up by inetd, which listens for requests and passes the control to in.whoisd when required (that is - when a request comes on port 43).

The inetd daemon forks and executes a copy of in.whoisd, the daemon associated with the whois service, handing the open file descriptor for the incoming socket connection to the new whois daemon.

After you get the handle, first thing you should do is to create a socket using that handle (attach to it).
Read the data after that.

Parsing the text should be no problem but if you have difficulties post the code and we'll help you.
0
 
EgeAuthor Commented:
well,

it 's clear that, no  socket connection and listenning required... which is already done by standart whois service, via the INET.

(unfortunately, in.whoisd and in.ege.whoisd the same thing in your sample! just changing the filename! here).

--------------- IMPORTANT PART --------------------
in this case, what I need is:
only the getting string into a VARIBLE.
string is the requested one by user, i.e
"whois subdom.mydom.com@whois.mydom.com"
inside the file /usr/sbin/in.whoisd
which is called each time whois request accepted via INET services...
--------------------------------------------------

{ the URL you give talks about the WHOIS, but I do NOT wanna use standart whois process.. I just one to use it as a known process to accept queries! }

thanx for your interest... but still I do not get my answer.

best regards...
0
 
bkdcCommented:
I understand, but the only way to do that is to write a whois daemon (in.ege.whoisd or whatever name you like) and use it instead of the default one: in.whoisd
0
 
EgeAuthor Commented:
:)

yes! but how!?

my problem is already accepting the requested string!

If I can get the string sent by whois command, I have no problem to process it!

How can I get the string which has been sent by whois command?

:)
0
 
bkdcCommented:
Told ya before. Make a nice little daemon. There's no other way, unless you use a sniffer (and that would be a REAL pain).
 Why do you find it so difficult ? Take some in.whoisd sources (i presume Linux comes with this king of source code) and tweak it to serve your needs. This way you won't have to write a fully compliant whois daemon from scratch.

PS: Sorry but I don't know any other (easy, hocus-pocus, 10 easy steps) way.
0
 
EgeAuthor Commented:
sorry that I accept your answer due the personel problems.
Thatks for your interest. Your answer about xinet.d configuration file did help me...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.