WiFi连接下,如何固定住IP地址

在WiFi连接下固定(静态)IP地址,通常需要通过你的"无线路由器"进行设置,而不是直接在连接WiFi的电脑或设备上操作(除非你的电脑直接连接了路由器,并且路由器是连接到互联网的唯一设备,这种情况较少见)。
以下是通用步骤,具体界面可能因路由器品牌(如 TP-Link, ASUS, Xiaomi, Netgear, Linksys 等)和型号略有不同:
"步骤一:登录路由器管理界面"
1. "找到路由器登录地址:" 通常输入 `192.168.1.1` 或 `192.168.0.1`。你可以在路由器底部标签上找到,或者查阅路由器说明书。少数路由器可能使用其他地址,如 `192.168.100.1`。 2. "打开浏览器:" 在你想要设置静态IP的电脑上打开网页浏览器(如 Chrome, Firefox, Edge)。 3. "输入路由器地址并登录:" 在浏览器地址栏输入上一步找到的路由器登录地址,按 Enter。 会弹出登录窗口,需要输入"用户名 (Username)" 和 "密码 (Password)"。 默认用户名和密码通常是 `admin/admin`、`admin`、`1234` 或路由器底部标签上的信息。如果你之前修改过,请使用你设置的账号和密码

相关内容:

同一个WiFi网络下,经常需要两台设备之间通讯。用来共享文件、开发调试或者其他。通常为了做到这一点,我们需要固定的ip地址,或者固定的域名,这样使用方就不用经常更换地址了。

通过路由器绑定IP地址

一般WiFI路由器都有此功能,以小米无线路由器举例。如下

登录进小米路由器


绑定IP

这个方法通常需要有路由器的管理权限。如果没有就只能用下面的方法了。

通过查看IP,配置Hosts绑定

windows下可以使用C:windowssystem32driveretchosts来配置自定义域名。linux下通过/etc/hosts来配置自定义域名。

ipconifg 在windows上查看

# 设置路由器的ip地址
192.168.99.44 www.aigrow.space

搭建局域网DNS,集中管理

windows下也可以使用 choco来管理安装包。这里使用bind9作为dns服务。



# 以管理员的方式启动命令行窗口
C:>choco install bind-toolsonly
Chocolatey v0.10.15
Installing the following packages:
bind-toolsonly
By installing you accept licenses for the packages.

bind-toolsonly v9.16.28 
bind-toolsonly package files install completed. Performing other installation steps.
The package bind-toolsonly wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?(es/ll - yes to all/o/rint): Y

# 下载后。。。通常会等待一段时间,有百分比提示
Extracting 64-bit C:ProgramDatachocolateylibbind-toolsonly	oolsBIND9.16.28.x64.zip to C:ProgramDatachocolateylibbind-toolsonly	oolscontent...
C:ProgramDatachocolateylibbind-toolsonly	oolscontent
 ShimGen has successfully created a shim for arpaname.exe
 ShimGen has successfully created a shim for BINDInstall.exe
 ShimGen has successfully created a shim for ddns-confgen.exe
 ShimGen has successfully created a shim for delv.exe
 ShimGen has successfully created a shim for dig.exe
 ShimGen has successfully created a shim for dnssec-cds.exe
 ShimGen has successfully created a shim for dnssec-dsfromkey.exe
 ShimGen has successfully created a shim for dnssec-importkey.exe
 ShimGen has successfully created a shim for dnssec-keyfromlabel.exe
 ShimGen has successfully created a shim for dnssec-keygen.exe
 ShimGen has successfully created a shim for dnssec-revoke.exe
 ShimGen has successfully created a shim for dnssec-settime.exe
 ShimGen has successfully created a shim for dnssec-signzone.exe
 ShimGen has successfully created a shim for dnssec-verify.exe
 ShimGen has successfully created a shim for host.exe
 ShimGen has successfully created a shim for mdig.exe
 ShimGen has successfully created a shim for named-checkconf.exe
 ShimGen has successfully created a shim for named-checkzone.exe
 ShimGen has successfully created a shim for named-compilezone.exe
 ShimGen has successfully created a shim for named-journalprint.exe
 ShimGen has successfully created a shim for named-rrchecker.exe
 ShimGen has successfully created a shim for named.exe
 ShimGen has successfully created a shim for nsec3hash.exe
 ShimGen has successfully created a shim for nslookup.exe
 ShimGen has successfully created a shim for nsupdate.exe
 ShimGen has successfully created a shim for rndc-confgen.exe
 ShimGen has successfully created a shim for rndc.exe
 ShimGen has successfully created a shim for tsig-keygen.exe
 ShimGen has successfully created a shim for vcredist_x64.exe
 The install of bind-toolsonly was successful.
  Software installed to 'C:ProgramDatachocolateylibbind-toolsonly	oolscontent'

Chocolatey installed 1/1 packages.
 See the log for details (C:ProgramDatachocolateylogschocolatey.log).

编辑配置文件


配置文件路径和文件目录结构

D:softdns>tree /F
卷 Data 的文件夹 PATH 列表
卷序列号为 1EC0-B189
D:.
│  managed-keys.bind
│  managed-keys.bind.jnl
│  named.conf
│  yrwp.ns.sz.cn.zone
│
└─log
        named.log

D:softdns>type named.conf
options {
    directory "D:softdns";
    listen-on port 53 { any; };
    allow-query { any; };
    recursion yes;
};

zone "yrwp.ns.sz.cn" {
    type master;
    file "yrwp.ns.sz.cn.zone";
};

logging {
    channel default_log {
        file "D:softdnslognamed.log";
        severity info;
        print-time yes;
        print-severity yes;
        print-category yes;
    };
    category default { default_log; };
};

D:softdns>type yrwp.ns.sz.cn.zone
$TTL 86400
@ IN SOA ns1.yrwp.ns.sz.cn. admin.yrwp.ns.sz.cn. (
    2023101001 ; Serial
    3600       ; Refresh
    1800       ; Retry
    1209600    ; Expire
    86400 )    ; Minimum TTL
@ IN NS ns1.yrwp.ns.sz.cn.
ns1 IN A 192.168.99.35

; n1 解析到192.168.99.44
n1 IN A 192.168.99.44

; 其他解析到192.168.99.1
* IN A 192.168.99.1

# 命令行启动named
C:ProgramDatachocolateylibbind-toolsonly	oolscontent
amed.exe -c named.conf -f
# 命令行启动named,并输出日志信息到控制台
C:ProgramDatachocolateylibbind-toolsonly	oolscontent
amed.exe -c named.conf -g

D:softdns>nslookup n1.yrwp.ns.sz.cn
服务器:  UnKnown
Address:  192.168.99.35

名称:    n1.yrwp.ns.sz.cn
Address:  192.168.99.44

然后配置好客户端的DNS服务,就可以获得如下效果:






D:softdns>ping n1.yrwp.ns.sz.cn

正在 Ping n1.yrwp.ns.sz.cn  具有 32 字节的数据:
来自 192.168.99.44 的回复: 字节=32 时间=2ms TTL=128
来自 192.168.99.44 的回复: 字节=32 时间=2ms TTL=128
来自 192.168.99.44 的回复: 字节=32 时间=2ms TTL=128
来自 192.168.99.44 的回复: 字节=32 时间=2ms TTL=128

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章