Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Friday, May 6, 2022

Setting system DNS servers using Ansible

 So I've got a project at work that's allowing me to use more Ansible.. and I love it!  Anyway we've been using Cisco's Umbrella appliances for safe DNS services but now they are going away. So.. what to do about all the servers currently using those servers in a static fashion?

So in this situation Windows was actually a bit easier. We have three main sites and a few smaller locations that do not contain their own DNS servers. So this play associates the smaller sites subnets with the nearest main site. So after much assistance from #ansible on Libera.Chat here is what I have:


---
- name: Replacing Umbrella DNS on Windows
hosts: "{{ targets }}"
become: yes
become_method: runas
tasks:

- name: Edit Site1 DNS Settings on all network interfaces
win_dns_client:
adapter_names: '*'
ipv4_addresses:
- 10.10.16.11
- 10.10.16.12
log_path: C:\dns_log.txt
when: "(ansible_ip_addresses | ipaddr('10.10.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.25.0.0/16') | list)"

- name: Edit Site2 DNS Settings on all network interfaces
win_dns_client:
adapter_names: '*'
ipv4_addresses:
- 10.11.16.11
- 10.11.16.12
log_path: C:\dns_log.txt
when: "(ansible_ip_addresses | ipaddr('10.11.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.30.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.20.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.18.0.0/16') | list)"

- name: Edit Site3 DNS Settings on all network interfaces
win_dns_client:
adapter_names: '*'
ipv4_addresses:
- 10.13.16.11
- 10.13.16.12
log_path: C:\dns_log.txt
when: "(ansible_ip_addresses | ipaddr('10.13.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.22.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.21.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.44.0.0/16') | list)"

Next post I'll make is handling Linux.  thanks!

Tuesday, April 21, 2015

Remotely determining a mac address

So today I had need of finding the mac address of a license server.. this server is a virtual and currently my vcenter server is down.  So unbeknownst to me Windows has had a nice little built-in command since XP called GetMac.

Read more here: https://technet.microsoft.com/en-us/library/bb490913.aspx

For those who don;t want to read it let me give you the simplest syntax for it..


getmac /s <hostname> /u domain\user /p <password>

That's it.  Short, simple and quick.. does exactly what you want it to.  Also there's no subnet limitations like with arp -a.


Enjoy.

Wednesday, July 2, 2014

EventID 4319: A duplicate name has been detected on the TCP network.

Just noticed today that one of our terminal servers has been getting this error now for a few days at least.. every couple of hours.

Scenario: Three Windows Server 2003 boxes running Terminal Services, each with two nics and NLB setup.

After Googling I tried disabling File and Printer sharing on the 'backend' nic, no recurrence of the error yet and it's been 6 hours.

WOOT.

I will be disabling that on the other two hosts as well.