摘要:同一个WiFi网络下,经常需要两台设备之间通讯。用来共享文件、开发调试或者其他。通常为了做到这一点,我们需要固定的ip地址,或者固定的域名,这样使用方就不用经常更换地址了。通过路由器绑定IP地址一般WiFI路由器都有此功能,以小米无线路由器...
同一个WiFi网络下,经常需要两台设备之间通讯。用来共享文件、开发调试或者其他。通常为了做到这一点,我们需要固定的ip地址,或者固定的域名,这样使用方就不用经常更换地址了。
通过路由器绑定IP地址
一般WiFI路由器都有此功能,以小米无线路由器举例。如下
登录进小米路由器
绑定IP
这个方法通常需要有路由器的管理权限。如果没有就只能用下面的方法了。
通过查看IP,配置Hosts绑定
windows下可以使用C:\windows\system32\driver\etc\hosts来配置自定义域名。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 [Approved]
bind-toolsonly package files install completed. Performing other installation steps.
The package bind-toolsonly wants to run chocolateyInstall.ps1.
Note: If you dont 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?([Y]es/[A]ll - yes to all/[N]o/[P]rint): Y
# 下载后。。。通常会等待一段时间,有百分比提示
Extracting 64-bit C:\ProgramData\chocolatey\lib\bind-toolsonly\tools\BIND9.16.28.x64.zip to C:\ProgramData\chocolatey\lib\bind-toolsonly\tools\content...
C:\ProgramData\chocolatey\lib\bind-toolsonly\tools\content
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:\ProgramData\chocolatey\lib\bind-toolsonly\tools\content
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
编辑配置文件
配置文件路径和文件目录结构
D:\soft\dns>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:\soft\dns>type named.conf
options {
directory "D:\\soft\\dns\\";
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:\\soft\dns\\log\\named.log";
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category default { default_log; };
};
D:\soft\dns>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:\ProgramData\chocolatey\lib\bind-toolsonly\tools\content\named.exe -c named.conf -f
# 命令行启动named,并输出日志信息到控制台
C:\ProgramData\chocolatey\lib\bind-toolsonly\tools\content\named.exe -c named.conf -g
D:\soft\dns>nslookup n1.yrwp.ns.sz.cn
服务器: UnKnown
Address: 192.168.99.35
名称: n1.yrwp.ns.sz.cn
Address: 192.168.99.44
然后配置好客户端的DNS服务,就可以获得如下效果:
D:\soft\dns>ping n1.yrwp.ns.sz.cn
正在 Ping n1.yrwp.ns.sz.cn [192.168.99.44] 具有 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
版权声明:除特别声明外,本站所有文章皆是来自互联网,转载请以超链接形式注明出处!