设为首页 加入收藏

TOP

cmd 配置dchp服务器
2019-08-26 07:29:10 】 浏览:21
Tags:cmd 配置 dchp 服务器

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.0 名字为MainScope,备注为PrimaryScope
    建立地址池,分发的IP范围为192.168.1.1-254,其中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 1

执行时:

netsh -c "dhcp server" -r RemoteComputer -f dhcp_scope_192.168.1.0.bat

其中,dhcp server是上下文,-f dhcp_scope_192.168.1.0.bat是执行的脚本文件或网络路径。 

 

要删除建立的作用域:

netsh -c "dhcp server" -r RemoteComputer del scope  192.168.1.0 dhcpfullforce

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Exchange-重建见证服务器和目录 下一篇解决“要登录到这台远程计算机,你..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目