我是我公司的微软DNS管理员。Linux管理员正在使用nsupdate为他的服务器向Microsoft添加多个DNS A和PTR记录。这些记录带有时间戳,DNS清除在我们配置的时间框架之后删除它们。他如何运行命令只添加静态条目?
发布于 2019-09-04 18:36:33
以下是我们在Management上使用的解决方案(并不完全是您所要求的解决方案,但我们决定,在我们的情况下,这将是唯一可行的解决方案)
复制步骤:
transport.py
文件中的一行。(不幸的是,我似乎再也找不到台词了.(您可以跳过它,您希望通过用户名和密码进行身份验证。如果必须对dns服务器进行身份验证,则仍然需要Kerberos委托。只有当您在DNS服务器上打开winRM时才能跳过此操作(而不是推荐!)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"
#!/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()
https://serverfault.com/questions/972862
复制相似问题