cmd 配置dchp服务器
2024-10-19 11:46:46
1.安装DHCP服务器角色,这样在netsh下才会有dhcp上下文
2.编写配置dhcp的脚本
从命令行运行netsh有两种语法:
比如要获取已经配置的网络接口列表
1.写全
netsh -r RemoteComputerName interface ipv4 show interface
其中:-r RemoteComputerName 是指定要操作的远程主机或本机的计算机名,interface ipv4 是netsh下的上下文,show interface 是interface ipv4 下获取网络接口列表的命令。
2.netsh -c Context -r RemoteComputerName Command
其中,Context为待操作的上下文标识符,RemoteComputerName 是指定要操作的远程主机或本机的计算机名,command 是待执行的命令。
netsh -c "interface ipv4" -r RemoteComputer show interfaces
有了以上的了解后,我们在编写dhcp的脚本时,使用第二种写法,这样的脚本简单,方便指定远程主机,不会写死。
要求: 建立作用域192.168.1. 名字为MainScope,备注为PrimaryScope
建立地址池,分发的IP范围为192.168.1.-,其中1-25的IP排除不能分配
批处理脚本dhcp_scope_192.168.1.0.bat
add scope 192.168.1.0 255.255.255.0 MainScope PrimaryScope
scope 192.168.1.0 add iprange 192.168.1.1 192.168.1.254
scope 192.168.1.0 add excluderange 192.168.1.1 192.168.1.25
scope 192.168.1.0 set state
执行时:
netsh -c "dhcp server" -r RemoteComputer -f dhcp_scope_192.168.1..bat
其中,dhcp server是上下文,-f dhcp_scope_192.168.1.0.bat是执行的脚本文件或网络路径。
要删除建立的作用域:
netsh -c "dhcp server" -r RemoteComputer del scope 192.168.1.0 dhcpfullforce
最新文章
- 制作动画或小游戏——CreateJS基础类(一)
- meta之renderer
- 8个实用的页面布局和用户界面jQuery插件
- ASPxGridView的自动排序(写在onCustomUnboundColumnData()事件中)
- HDU-4687 Boke and Tsukkomi 带花树,枚举
- 1、Python django 框架下的word Excel TXT Image 等文件的上传
- VIM学习一: VIM命令学习及插件介绍
- vxlan基础
- P3649 [APIO2014]回文串
- Java8 in action
- Numpy 矩阵
- 【SpringAop】【统一日志处理】注解方式理解以及使用
- php与redis使用经验分享 (转载)
- Android学习之Design Support Library中TextInputLayout的使用
- django 自定义中间件 middleware
- 怎么在eclipse中访问webservice
- 使用matplotlib绘图(一)之折线图
- 1-2 Sass安装(windows版)
- 使用Material Design 创建App翻译系列---列表和卡片集的创建
- sql报字段过大的错误解决方法
热门文章
- activemq的消息确认机制ACK
- Java 8 文件操作(转)
- Bash特殊变量:$0, $#, $*, $@, $?, $$实战
- CORS 实战 专题
- springboot集成schedule(深度理解)
- 陌陌架构分享 – Apple Push Notification Service
- 2. Java面向对象之泛型-构造方法中使用
- pdb 调试
- [爬虫]爬虫时碰到的IOError: [Errno ftp error] [Errno 10060]错误的原因以及解决方法
- go语言 nsq源码解读四 nsqlookupd源码options.go、context.go和wait_group_wrapper.go