Re: IP ADDRESS



Hi
I can see that the program is fine, I am just utterly confused as to why one
would be the least interesrted in doing it.
In the words of the inimitable Pauline "Please Explain"
Peter McMurray

"GlenB" <batchelg@xxxxxxxxxxxxx> wrote in message
news:8189c925-bfc5-4622-9603-ae4e536ad077@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The following code requires that you either don't have any of the
machines in DNS or RDNS, or that you have them all in DNS & RDNS. If
you are using it for identification only, you can create your own DNS
map in D3 and do the lookups yourself if you have a mixed/incomplete
DNS environment. The "REMOTE" in the call name is relative to the fact
that I'm asking Linux on the remote(server) side who the client side
is for a specific PIB. Enjoy!

SUBROUTINE GET.REMOTE.IP(REMOTE_IP)
NETWORK = "192.168.0.0"
!
! GET LINUX DEVICE NAME
!
PORT.NUM = SYSTEM(22)
EXECUTE 'LIST-LINES ':PORT.NUM CAPTURING OUTPUT
OUTPUT = OUTPUT<2>
CONVERT CHAR(32) TO CHAR(254) IN OUTPUT
LASTIDX = DCOUNT(OUTPUT,CHAR(254))
DEVID = OUTPUT<LASTIDX>
DEVID = SWAP(DEVID,"/dev/","")
!
! GET THE HOSTNAME FOR THE DEVICE
!
EXECUTE '!w -h' CAPTURING OUTPUT
LNS = DCOUNT(OUTPUT,CHAR(254))
IDX = 0
FOR PTR = 1 TO LNS
TLINE = OUTPUT<PTR>
CONVERT CHAR(32) TO CHAR(254) IN TLINE
LOCATE DEVID IN TLINE SETTING VM THEN
IDX = PTR
END
NEXT PTR
IF IDX > 0 THEN
WLINE = OUTPUT<IDX>
END ELSE
RETURN
END
CONVERT CHAR(32) TO CHAR(254) IN WLINE
LNS = DCOUNT(WLINE,CHAR(254))
IPCOL = 0
HOSTNAME = ''
FOR PTR = 1 TO LNS
IF WLINE<PTR> # "" AND IPCOL = 1 THEN
HOSTNAME = WLINE<PTR>
GO DONE
END
IF WLINE<PTR> = DEVID THEN
IPCOL = 1
END
NEXT PTR
STOP
DONE:
HOSTNAME = TRIM(HOSTNAME)
!
! DETERMINE IF HOSTNAME IS IP OR DNS RESOLVED HOSTNAME
! IF IT'S NOT AN IP, GET THE IP FROM LOCAL DNS
!
IPADDR = ''
IF HOSTNAME[1,3] # NETWORK[1,3] THEN
EXECUTE '!host ':HOSTNAME CAPTURING IPADDR
CONVERT CHAR(32) TO CHAR(254) IN IPADDR
LNS = DCOUNT(IPADDR,CHAR(254))
REMOTE_IP = IPADDR<LNS>
END ELSE
REMOTE_IP = HOSTNAME
END
RETURN


.



Relevant Pages

  • Re: IP ADDRESS
    ... to me with the least amount of client machine configuration or programming. ... machines in DNS or RDNS, or that you have them all in DNS & RDNS. ... GET THE HOSTNAME FOR THE DEVICE ... FOR PTR = 1 TO LNS ...
    (comp.databases.pick)
  • Re: IP ADDRESS
    ... machines in DNS or RDNS, or that you have them all in DNS & RDNS. ... GET THE HOSTNAME FOR THE DEVICE ... LNS = DCOUNT) ... FOR PTR = 1 TO LNS ...
    (comp.databases.pick)
  • Re: adding a second nic
    ... > internal Active Directory domain zone. ... with a gateway of 192.168.1.1 and assign it in DNS as a domain name ... and use that as my internet connection ... on 192.168.1.200 called outside, with hostname ohostname. ...
    (microsoft.public.win2000.dns)
  • Re: Security flaw in ALCATEL/THOMSON Speed Touch Pro ADSL modems
    ... | because it's a way DHCP and DNS are supposed to work and it's ... firmware simply doesn't validate any further Hostname given to it, ... this flaw allows to corrupt the local zone file ...
    (Bugtraq)
  • Re: Bug in Graphical Network Configuration???
    ... I have assigned the static address for my FC5 box because I am serving ... FC5 box has something to do with the Samba since windows machines uses ... addresses - it might add them (machine hostname and FQDN) to the ... The ISP's DNS server numerical IP addresses. ...
    (Fedora)