Home php教程 php手册 PHP重启路由器以更换IP地址程序

PHP重启路由器以更换IP地址程序

May 25, 2016 pm 04:53 PM
router

本文章来给各位同学介绍一个关于PHP重启路由器以更换IP地址程序,如果你对此有兴趣不防进入参考哦。

在采集大批量数据时常常会触发对方服务器的“自我保护”,请求过于频繁就限制访问。这时需要停留很长一段时间(十几分钟到几十分钟不等)才能恢复访问,这样采集数据的速度就受到非常大的限制。

解决方法有两个:

1 通过图片识别绕过验证码机制,告诉服务器:我不是蜘蛛,我是人。不信你瞧,我能看懂验证码。

2 更换IP,告诉服务器:我不是张三,我是李四。不信你瞧,我的IP地址和张三的不一样。

第一个方法难度稍高一点而且不靠谱,等哪天对方服务器升级了验证码了,这边也得跟进,麻烦多;而ISP(电信、联通、移动)那儿有很多IP,每次联网都会分配一个新的IP,因此方法二比较好。

以我的TP-LINK路由器为例,找到“网络参数”>“WAN口设置”,可以看到“自动连接”设置和“断线”按钮。每次点击“断线”按钮,就向ISP重新拨号,此时就换了一个IP。但大批量数据的采集需要的时间比较长,不可能总有人在旁边守着,最好能在PHP代码中,一旦发现被限制了就重启一次,这就回到本文的主题了:《通过PHP函数重启路由器以更换IP》

打开chrome浏览器的调试模式,然后点击“断线”按钮,看“Network”网络请求,可以看到实际执行的地址是:“http://192.168.0.1/userRpm/PPPoECfgRpm.htm?wantype=2&acc=65541234&psw=Hello123World&VnetPap=0&linktype=2&Disconnect=%B6%CF+%CF%DF”

然后模拟请求这个地址,经测试确实可以更换IP地址(通过http://api.akcms.com/myip.php可以看到当前IP)。接下来的就简单了:就用PHP使用Curl组件来实现这个请求的过程,我封装了一个函数resetip,具体代码如下:

<?php
//本脚本测试重启路由器的WLAN连接
resetip();
function resetip() {
    $username = &#39;admin&#39;;
    $password = &#39;123456&#39;;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, &#39;http://192.168.0.1/userRpm/PPPoECfgRpm.htm?wantype=2&acc=65541234&psw=Hello123World&VnetPap=0&linktype=2&Disconnect=%B6%CF+%CF%DF&#39;);
    curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_exec($ch);
    curl_close($ch);
}
?>
Copy after login

高亮处需要根据自己的情况修改,路由器地址有的是192.168.1.1,重启地址也各有不同,但大同小异,自己改改。

教程网址:

欢迎收藏∩_∩但请保留本文链接。

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
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)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
What does router sys mean? What does router sys mean? Aug 23, 2022 am 10:42 AM

The sys of the router means system operating status indication, and the full name is System; the router uses the sys indicator light to inform the user of the operating status of the device. If the router is faulty or restarting, the indicator light will flash; the indicator light of the router can be divided into power Indicator light, sys system indicator light, LAN indicator light and WAN indicator light.

Can the router be placed upside down? Can the router be placed upside down? Sep 22, 2023 pm 02:11 PM

Can. However, you need to pay attention to some issues: 1. Placing the router upside down may have a certain impact on heat dissipation, causing heat to accumulate at the bottom of the router, affecting the heat dissipation effect. Long-term overheating may reduce the performance of the router and adversely affect its lifespan. ; 2. Placing the router upside down may affect the operation and management of the device, and the indicator lights and interfaces may be blocked or inconvenient to operate; 3. Placing the router upside down may also have a certain impact on network security, and the default user name and password may cause This information is more susceptible to prying eyes.

What are the benefits of turning on ipv6 on the router 'Advantages of using the latest IPv6' What are the benefits of turning on ipv6 on the router 'Advantages of using the latest IPv6' Feb 06, 2024 pm 05:34 PM

Students who know computers all know that if our computer wants to connect to the network, it must have an IP address. This IP address can be manually configured, such as 172.16.19.20; it can also be automatically obtained by the DHCP server of the computer network card, such as 192.168.1.100 etc. These IP addresses are what we often call IPV4 addresses, and the corresponding IPV6 is also a type of IP address. What is IPV6 IPV6 is a new IP address that emerged in response to the exhaustion of IPV4 address resources. Its full name is "Internet Protocol Version 6", and its Chinese name is the sixth generation of Internet Protocol. The number of IPv6 addresses is theoretically 2^128

What does router sn mean? What does router sn mean? Oct 27, 2022 pm 05:21 PM

In routers, sn stands for "Serial Number", which means "serial number" and refers to the factory number of the router. The router serial number (SN) and physical address are both hardware identifiers, which are unique; the router will be under warranty only if the router's serial number is kept intact. The router serial number SN can be seen directly in the manual and on the back of the router.

How many lights on the router are normal? 'Recommended detailed explanation of the normal status of the router indicator lights' How many lights on the router are normal? 'Recommended detailed explanation of the normal status of the router indicator lights' Feb 06, 2024 pm 09:12 PM

The first light is on, indicating that the router is powered on. Which port is plugged in, the light of which port is on, and flashing means data is being transmitted. Wireless routers usually have three indicator lights: SYS, LAN and WAN. When the wireless router is powered on, the SYS light will light up. When the wireless router is connected to the network modem, the WAN light will light up. The LAN light corresponds to each interface of the wireless router. As long as the network cable is inserted into the corresponding interface, the corresponding LAN light will light up. 1. If it keeps flashing, it means it is transmitted by data, and the router settings should be normal. 2. If you have always been able to access the Internet, but you can't get online recently; it is probably a problem with the external line, that is, a problem with the operator (usually there is a problem with the line, causing the data signal to attenuate too much, although the line is good)

Which one is faster, gateway or router? Which one is faster, gateway or router? Jun 19, 2023 pm 03:06 PM

The difference between gateway WiFi and router WiFi is mainly reflected in three aspects: function, number of terminals that support Internet access, and WiFi signal coverage. Gateway WiFi is a combination of optical modem and router. It has more functions, but it supports fewer Internet devices and the WiFi signal coverage is not as good as router WiFi.

Will placing the router upside down have any impact on the network? Will placing the router upside down have any impact on the network? Sep 22, 2023 pm 04:45 PM

Placing the router upside down may have some effects on the network, including reduced signal coverage, blocked signal transmission, poor temperature and heat dissipation, and reduced network speed. Detailed introduction: 1. The signal coverage is reduced. Routers are usually designed to radiate signals outward in a horizontal direction. Therefore, placing the router upside down may cause the signal coverage to be reduced, which may cause signal in some areas. Weakening, thus affecting the stability and speed of the connection; 2. Signal transmission is blocked. Placing the router upside down may cause signal transmission to be blocked, etc.

What is the impact of turning off dhcp on the router? What is the impact of turning off dhcp on the router? Dec 01, 2023 pm 04:01 PM

The impact of turning off dhcp on the router: 1. The client cannot automatically obtain an IP address; 2. The IP address needs to be configured manually; 3. It may cause network connection problems; 4. It affects the communication of network devices; 5. IP address conflicts; 6. Unable to proceed Dynamic address allocation; 7. Network isolation cannot be performed; 8. Traffic control cannot be performed; 9. Access control cannot be performed. It is recommended that before turning off the DHCP service, carefully consider whether it really needs to be turned off, or keep the DHCP service to ensure that the client can automatically obtain the correct IP address.

See all articles