Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

IPv6 Logging
Welcome, Guest. Please login or register.
December 03, 2008, 02:04:03 PM
11305 Posts in 1249 Topics by 498 Members
Latest Member: katCheeme
Experts Round Table Network  |  Webservers  |  Apache  |  IPv6 Logging « previous next »
Pages: [1]
Author Topic: IPv6 Logging  (Read 1059 times)
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 489



WWW
« on: May 30, 2007, 03:50:18 PM »

http://www.loganalyzer.net/log-analyzer/ipv6-log-analysis.html shows how an IPv6 log entry would look like. Is there an option to enable this because I am trying to add IPv6 support for my web applications like banning script, log script etc. Also on same topic how do I convert an IPv4 address to an IPv6 address? Example 1.2.3.4 becomes ????:????:????:????:????:????:????:???? thanks!
Logged

[x] Fight | www.crypticmauler.com
"You must be
rdivilbiss
Governing Council Member
*
Offline Offline

Posts: 414



WWW
« Reply #1 on: May 30, 2007, 05:15:40 PM »

How do I convert an IPv4 address to an IPv6 address? Example 1.2.3.4 becomes ????:????:????:????:????:????:????:???? thanks!

I don't know but I'm afraid we are all going to have to learn that very soon.  Ergo, I am monitoring so I can piggy back off the answer to your question.
Logged

Rod
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 489



WWW
« Reply #2 on: May 30, 2007, 07:48:26 PM »

I think I figured it out =oD

68.45.98.34

first take each part and consider it a decimal value and then convert it to hex so
68 would be 44
45 would be 2D
98 would be 62
34 would be 22

Then IPv6 IP equivalent would be

442D:6222 in short form and 0:0:0:0:0:0:442D:6222 in long form or could be 442D:6222:0:0:0:0:0:0 don't know that for sure yet, will read up more in the RFC.
Logged

[x] Fight | www.crypticmauler.com
"You must be
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #3 on: May 31, 2007, 10:35:06 AM »

the RFC 1897 defines this schema to integrate existing ip v4 addresses in a v6 format :

Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 489



WWW
« Reply #4 on: May 31, 2007, 12:01:48 PM »

Code
Language: php (GeSHi-highlighted)
<?php
/*
* Copyright (C) 2007 CrYpTiC MauleR <http://www.expertsrt.net/images/cm_email.gif>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

 
/*
* @desc    Converts An IPv4 IP Address To An IPv6 IP Address
* @param   str $ip
* @return  str
*/

function ipv4_to_ipv6($ip)
{
   if (-1 !== ip2long($ip)) /* Check If Valid IPv4 IP */
   {
       $octets = explode('.', $ip);
       $ip = '0:0:0:0:0:0:';
       foreach ($octets as $octet => $value)
       {
           if (2 === $octet)
           {
               $ip .= ':';
           }                  
           $ip .= ltrim(dechex($value), '0'); /* Remove Leading Zeroes */
       }
       return $ip;
   }
   return false;
}
 
?>

I made the above to convert an IPv4 IP to an IPv6 IP with leading zero compression. Also used http://www.php.net/manual/en/function.ip2long.php#71957 to make IPv6 IPs long so can insert into database more easily and do range checks etc. I'm still not sure if I did the above conversion correctly since I have yet to check out the RFC, so please correct me if I have not. Thanks.
« Last Edit: May 31, 2007, 12:06:33 PM by CrYpTiC_MauleR » Logged

[x] Fight | www.crypticmauler.com
"You must be
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 489



WWW
« Reply #5 on: June 02, 2007, 05:51:21 PM »

the IPv6 ip2long function linked above is incorrect. It does not correctly convert an IPv6 address into long format. I have had to make my own to properly convert it and handle the large address space. Basically FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF to long format should equal 340282366920938463463374607431768211455 NOT 2147483647 as the incorrect function is outputting.
Logged

[x] Fight | www.crypticmauler.com
"You must be
Pages: [1]
« previous next »
    Jump to: