Home Backend Development PHP Tutorial 如何看ipv6的地址范围

如何看ipv6的地址范围

Jun 13, 2016 pm 01:24 PM
end php quot start

怎么看ipv6的地址范围啊
我不会看ipv6的地址范围,比如下面这两个地址范围是指从哪个地址到哪个地址啊?
2406:6200::|32
240e:100::|24
为什么平时的ip库都是分开的,放在同一个表中会有什么问题吗?

------解决方案--------------------
这都是16进制表示,2字节一个:。

::表示接下来的都是0.

mysql还是可以操作的,unhex啊,substring,replace啊,看你需求了。
------解决方案--------------------
IP地址是可以按照字符串比较大小的, 要计算范围内的每一个IP, 可以gmp/bc直接当做大数运算, 我说的是PHP, 你有需求可以给你写个示例?
------解决方案--------------------

PHP code
[User:root Time:09:54:16 Path:/home/liangdong/php]$ php ip.php 
2406:6200:0000:0000:0000:0000:0000:0000[User:root Time:09:54:17 Path:/home/liangdong/php]$ cat ip.php 
<?php $ipv6_start = "2406:6200::";
$ipv6_end = "240e:100::";

// 扩展ipv6格式方便阅读
$bin_start = inet_pton($ipv6_start);
$bin_end = inet_pton($ipv6_end);
$start = unpack('H*0', $bin_start)[0];
$start = str_split($start, 4);
$start = implode(":", $start);
echo $start;

/* 作为大数运算, 可以遍历start, end内所有IP地址
$start = gmp_init($start, 16);
$end = unpack('H*0', $bin_end)[0];
$end = gmp_init($end, 16);
echo gmp_strval($start, 16);
*/
?>
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

PHP code
[User:root Time:09:54:16 Path:/home/liangdong/php]$ php ip.php
2406:6200:0000:0000:0000:0000:0000:0000[User:root Time:09:54:17 Path:/home/liangdong/php]$ cat ip.php
$ipv6_start = "2……

------解决方案--------------------
2400:ff00::|32
应该是从
2400:ff00:0000:0000:0000:0000:0000:0000

2400:ff00:0000:0000:0000:0000:ffff:ffff
后面的CIDR是位数, 32位就是ffff:ffff


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles