阿里云解析和windows服务器批量添加域名解析

2020-11-12

python使用winrm操作windows

安装模块

pip install pywinrm

windows系统服务器需要开启 winrm 服务

具体开启方法:

cmd命令行输入:

# 开启服务
1.winrm quickconfig
 会有两次确认

# 查看监听端口等信息
2.winrm e winrm/config/listener

# 授权
3.winrm set winrm/config/service/auth @{Basic="true"}

# 不加密模式
4.winrm set winrm/config/service @{AllowUnencrypted="true"}

上面的cmd命令可以写成一个.bat文件,在服务器上直接执行即可:

bat命令:

echo y| winrm quickconfig
echo y| winrm quickconfig
winrm e winrm/config/listener
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}

示例:

# -*- coding = utf-8 -*-
import winrm

con = winrm.Session('http://127.0.0.1:5985/wsman', auth=("administrator", "123456"))

con.run_cmd("ipconfig")

项目

地址:https://github.com/fish2018/dnstool.git

背景

项目生产环境分批切K8s时,由于官网在使用一级域名,所以无法直接泛域名解析到Ingress Controller;
只能对每个ingress的域名进行单独配置records

功能

  1. 阿里云private_zone批量添加record
  2. windows DNS批量添加record

安装依赖

pip install -r requirements.txt

修改配置信息

配置文件: config.py

运行

入口文件run.py

python3 run.py

标题:阿里云解析和windows服务器批量添加域名解析
作者:fish2018
地址:http://devopser.org/articles/2020/11/12/1605162554399.html