Szolgáltatót megkeresni a Whois-ből
2021-05-15T21:26:47+02:00
2021-05-15T23:03:30+02:00
2022-08-12T02:41:46+02:00
tivisu
Szeretném ebből a csomó információból kivenni csak a szolgáltatót:

Connecting to server whois.iana.org ...Done Sending request for ip: 213.198.239.169 Starting to read socket Response: % IANA WHOIS server % for more information on IANA, visit http://www.iana.org % This query returned 1 object refer: whois.ripe.net inetnum: 213.0.0.0 - 213.255.255.255 organisation: RIPE NCC status: ALLOCATED whois: whois.ripe.net changed: 1993-10 source: IANA Whois Server: whois.ripe.net Connecting to server whois.ripe.net ...Done Sending request for ip: 213.198.239.169 Starting to read socket % This is the RIPE Database query service. % The objects are in RPSL format. % % The RIPE Database is subject to Terms and Conditions. % See http://www.ripe.net/db/support/db-terms-conditions.pdf % Note: this output has been filtered. % To receive output for a database update, use the "-B" flag. % Information related to '213.198.239.0 - 213.198.239.255' % Abuse contact for '213.198.239.0 - 213.198.239.255' is 'abuse@yu.net' inetnum: 213.198.239.0 - 213.198.239.255 netname: YUNET-NET descr: YUnet International descr: Belgrade country: RS admin-c: YIRT1-RIPE tech-c: YIRT1-RIPE status: ASSIGNED PA mnt-by: AS8771-MNT remarks: INFRA-AW created: 2006-06-29T16:10:05Z last-modified: 2013-07-18T11:12:59Z source: RIPE role: YUnet International RIPE Team address: YUnet International address: Dubrovacka 35/III address: 11000 Beograd address: Serbia phone: +381 11 3119901 fax-no: +381 11 3119901 admin-c: MM48930-RIPE admin-c: DP3756-RIPE tech-c: MM48930-RIPE tech-c: DP3756-RIPE nic-hdl: YIRT1-RIPE abuse-mailbox: abuse@yu.net mnt-by: AS8771-MNT created: 2007-06-25T10:55:22Z last-modified: 2018-07-23T13:16:04Z source: RIPE # Filtered % Information related to '213.198.192.0/18AS8771' route: 213.198.192.0/18 descr: YUnet International origin: AS8771 mnt-by: AS8771-MNT created: 2002-10-10T15:32:36Z last-modified: 2013-08-07T10:39:11Z source: RIPE % This query was served by the RIPE Database Query Service version 1.100 (HEREFORD)
Találtam egy scriptet az interneten, ami az IP számból kiolvassa az adatokat, ebből kellene nekem a szolgáltató neve. Talán a "netname:" az, ami megadja ezt a nevet az IP alapján.

A script, ami előhozza ezt az infót a következő:

<?php /* Program to get IP whois data */ $ip = "109.239.229.76"; $whois = get_whois($ip); echo $whois; /** Get the whois content of an ip by selecting the correct server */ function get_whois($ip) { $w = get_whois_from_server('whois.iana.org' , $ip); print "Response: " . PHP_EOL; print $w; print PHP_EOL; preg_match("#whois:\s*([\w.]*)#si" , $w , $data); $whois_server = $data[1]; print "Whois Server: $whois_server " . PHP_EOL; // now get actual whois data $whois_data = get_whois_from_server($whois_server , $ip); return $whois_data; } /** Get the whois result from a whois server return text */ function get_whois_from_server($server , $ip) { $data = ''; // Before connecting lets check whether server alive or not $server = trim($server); if(!strlen($server)) { print "Blank string provided for server" . PHP_EOL; die(); } // Create the socket and connect print "Connecting to server $server ..."; $f = fsockopen($server, 43, $errno, $errstr, 3); //Open a new connection if(!$f) { print "Failed"; return false; } print "Done" . PHP_EOL; // Set the timeout limit for read if(!stream_set_timeout($f , 3)) { die('Unable to set set_timeout'); #Did this solve the problem ? } // Send the IP to the whois server if($f) { print "Sending request for ip: $ip" . PHP_EOL; $message = $ip . "\r\n"; fputs($f, $message); } /* Theory : stream_set_timeout must be set after a write and before a read for it to take effect on the read operation If it is set before the write then it will have no effect : http://in.php.net/stream_set_timeout */ // Set the timeout limit for read if( !stream_set_timeout($f , 3) ) { die('Unable to stream_set_timeout'); #Did this solve the problem ? } // Set socket in non-blocking mode stream_set_blocking ($f, 0 ); // If connection still valid if($f) { print "Starting to read socket".PHP_EOL; while (!feof($f)) { //print "Read attempt...".PHP_EOL; $data .= fread($f , 128); } } // Now return the data return $data; } ?>
T
Mutasd a teljes hozzászólást!
<?php $ip = "109.239.229.76"; $netname = netname ( $ip ); print $netname; function netname ( $ip ) { $whois = get_whois ( $ip ); if ( preg_match ( '/netname:(?<netname>.*?)\n/', $whois, $matches ) ) { return ltrim ( $matches [ 'netname' ] ); } else {} } /** Get the whois content of an ip by selecting the correct server */ function get_whois($ip) { $w = get_whois_from_server('whois.iana.org' , $ip); // print "Response: " . PHP_EOL; // print $w; // print PHP_EOL; preg_match("#whois:\s*([\w.]*)#si" , $w , $data); $whois_server = $data[1]; // print "Whois Server: $whois_server " . PHP_EOL; // now get actual whois data $whois_data = get_whois_from_server($whois_server , $ip); return $whois_data; } /** Get the whois result from a whois server return text */ function get_whois_from_server($server , $ip) { $data = ''; // Before connecting lets check whether server alive or not $server = trim($server); if(!strlen($server)) { // print "Blank string provided for server" . PHP_EOL; die(); } // Create the socket and connect // print "Connecting to server $server ..."; $f = fsockopen($server, 43, $errno, $errstr, 3); //Open a new connection if(!$f) { // print "Failed"; return false; } // print "Done" . PHP_EOL; // Set the timeout limit for read if(!stream_set_timeout($f , 3)) { die('Unable to set set_timeout'); #Did this solve the problem ? } // Send the IP to the whois server if($f) { // print "Sending request for ip: $ip" . PHP_EOL; $message = $ip . "\r\n"; fputs($f, $message); } /* Theory : stream_set_timeout must be set after a write and before a read for it to take effect on the read operation If it is set before the write then it will have no effect : http://in.php.net/stream_set_timeout */ // Set the timeout limit for read if( !stream_set_timeout($f , 3) ) { die('Unable to stream_set_timeout'); #Did this solve the problem ? } // Set socket in non-blocking mode stream_set_blocking ($f, 0 ); // If connection still valid if($f) { // print "Starting to read socket".PHP_EOL; while (!feof($f)) { //print "Read attempt...".PHP_EOL; $data .= fread($f , 128); } } // Now return the data return $data; } ?>
Mutasd a teljes hozzászólást!

abcd