首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用nsupdate在Microsoft DNS中添加静态DNS条目。

使用nsupdate在Microsoft DNS中添加静态DNS条目。
EN

Server Fault用户
提问于 2019-06-25 19:12:10
回答 1查看 1.9K关注 0票数 1

我是我公司的微软DNS管理员。Linux管理员正在使用nsupdate为他的服务器向Microsoft添加多个DNS A和PTR记录。这些记录带有时间戳,DNS清除在我们配置的时间框架之后删除它们。他如何运行命令只添加静态条目?

EN

回答 1

Server Fault用户

发布于 2019-09-04 18:36:33

以下是我们在Management上使用的解决方案(并不完全是您所要求的解决方案,但我们决定,在我们的情况下,这将是唯一可行的解决方案)

复制步骤:

  1. 在一个Windows主机上配置WinRM (我们使用了https://support.microsoft.com/en-us/help/2019527/how-to-configure-winrm-for-https服务器)
  2. 在您的主机或集中式主机上安装python和吡温林。我们将整个内部主机和IP管理托管在一个负责此角色的We服务器上。
  3. 从有权操作DNS条目的用户帐户中获取用户名和密码或Kerberos Keytab文件。
  4. 充当WinRM端点的Windows主机帐户需要启用Kerberos委托,以便将凭据转发到目标DNS服务器
  5. 安装Windows RSAT以使dnscmd.exe在WinRM主机上可用。
  6. 为了使kerberos能够使用下面提供的脚本,我必须更改pywinrm提供的transport.py文件中的一行。(不幸的是,我似乎再也找不到台词了.(您可以跳过它,您希望通过用户名和密码进行身份验证。如果必须对dns服务器进行身份验证,则仍然需要Kerberos委托。只有当您在DNS服务器上打开winRM时才能跳过此操作(而不是推荐!)
  7. 按照以下方式执行脚本:kinit -f -t /path/to/krb5.keytab -k username@DOMAIN ; LANG=\"C.UTF-8\" ; /the/script/provided/below.py -m mywinrmhost.example.org -c "dnscmd.exe dns dns server.example.org /recordadd example.org entire.example.org /CreatePTR newentrie 10.20.30.40"
代码语言:javascript
运行
复制
#!/usr/bin/python3

#https://support.microsoft.com/en-us/help/2019527/how-to-configure-winrm-for-https

import winrm, sys, getpass, argparse
__author__ ='Daywalker (at least partially)'

parser = argparse.ArgumentParser(description='This is a basix winRM script')
parser.add_argument('-a','--auth',help='Authentication type (plaintext|kerberos)', default="kerberos", required=False)
parser.add_argument('-m','--host', help='Hostname or IP address of the target Windows machine',required=False)
parser.add_argument('-u','--user',help='Username for authentication', required=False)
parser.add_argument('-p','--password',help='Password for the given username', required=False)
parser.add_argument('-c','--command',help='Command to execute', required=False)

args = parser.parse_args()

hostname = args.host
user = args.user
pw = args.password
command = args.command
auth = args.auth;

if not hostname:
    hostname = "mytargetwinrmhost.example.org"
if args.auth != 'kerberos':
    if not user:
        user = input("Enter a username for the WinRM connection to " + hostname + ": ")

    if not pw:
        print("Enter password for " + user)
        pw = getpass.getpass()

    if not user:
        print("Username missing");
        sys.exit(1);

    if not pw:
        print("Empty passwords not allowed");
        sys.exit(1);

if not hostname:
    print("Hostname missing");
    sys.exit(1);

#s = winrm.Session(hostname,auth=(user,pw),transport='plaintext')
s = winrm.Session(hostname,auth=(user,pw),transport=auth)

if not command:
    command = input("Please enter the command to execute: ")

r = s.run_cmd(command)
#print(r.status_code)
print(r.std_out.decode('437'))
print(r.std_err.decode('437'))
quit()
票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/972862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档