使用Javascript创建虚假IP地址

use*_*080 0 javascript random

我试图IP address使用以下javascript随机方法创建假.但不行.

任何人帮我找到正确的方法吗?

这是我的尝试:我看起来像("192.168.10.2")

 console.log(  Math.random(256) + "." + Math.random(256) + "." + Math.random(256) + "." + Math.random(256) );
Run Code Online (Sandbox Code Playgroud)

Sha*_*yal 9

代码应该是:

var ip = (Math.floor(Math.random() * 255) + 1)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0);
console.log(ip)
Run Code Online (Sandbox Code Playgroud)

代码(Math.floor(Math.random() * 255) + 1)意味着生成1到255之间的随机数.