当前位置:网站首页>How to solve the problem that after Tencent cloud sets static DNS, restarting the machine becomes dynamic DNS acquisition
How to solve the problem that after Tencent cloud sets static DNS, restarting the machine becomes dynamic DNS acquisition
2022-06-24 06:21:00 【shawyang】
Set-ExecutionPolicy Unrestricted -force
while((powershell -c {(get-process|findstr powershell).length}) -ne 2)
{
get-date -format HH:mm:ss:fffffff >> c:\aaa.txt;
start-sleep 1;
}
if((powershell -c {(get-process|findstr powershell).length}) -eq 2)
{
(get-wmiobject -class win32_networkadapterconfiguration -filter ipenabled=true).SetDNSServerSearchOrder(('10.123.119.98','10.12.216.180')) 2>$null;
exit
}
Code to be fine tuned , Put it in C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\setdns.ps1
dns Adjust the agent according to your own needs dns, You can add 、 reduce dns, for example :
Add
(get-wmiobject -class win32_networkadapterconfiguration -filter ipenabled=true).SetDNSServerSearchOrder(('10.123.119.98','10.12.216.180','114.114.114.114','8.8.8.8')) 2>$null;
reduce
(get-wmiobject -class win32_networkadapterconfiguration -filter ipenabled=true).SetDNSServerSearchOrder(('180.76.76.76')) 2>$null;
This script is written by me to set the static DNS Of , For some machines , The value in the code is 2 You can set dns, No machine handle 2 Change to 3 You can set dns success ( The concrete is 2 still 3 Or a bigger number , I watched the background after the restart powershell Number of processes )
2 On behalf of others powershell It's all done , Is executed setdns.ps1 In itself , Set up dns In the last step
and 3 The situation is , I have observed that there are always 1 individual powershell, There has always been , This situation ,3 On behalf of others that should be completed powershell It's all done , Next, we will carry out setdns.ps1 In itself
In code 2 and 3 I have encountered both situations , because cloudbase-init By calling powershell The code works , I guess the logic 2 and 3 The difference may be that the user-defined image has a resident boot plan task, which is weak powershell The process is placed in the background , If that's the case , Excepting 2 and 3, There may be 4、5、6 , etc. , Specifically, it depends on the background after startup powershell How many processes are there
边栏推荐
- Summary of basic notes of C language (I)
- Playing "honey in snow and ice city" with single chip microcomputer
- How to select cloud game platforms? Just pay attention to two points
- Solution to the 39th weekly game of acwing
- EEG microstate as a continuous phenomenon
- Easycvr development environment startup program reports an error import cycle not allowed solution
- Configure PHP development environment in MAC environment: apache+php+mysql
- A high-end router antenna connection mechanism that can simultaneously deploy and store antennas
- How to resolve the domain name? How to choose a domain name?
- Precautions for selecting high frequency signal generator
猜你喜欢

Technology is a double-edged sword, which needs to be well kept

ServiceStack. Source code analysis of redis (connection and connection pool)

The product layout is strengthened, the transformation of digital intelligence is accelerated, and FAW Toyota has hit 2022million annual sales

Manual for automatic testing and learning of anti stepping pits, one for each tester

What is the difference between a white box test and a black box test

One line of keyboard

A cigarette of time to talk with you about how novices transform from functional testing to advanced automated testing

Enter the software test pit!!! Software testing tools commonly used by software testers software recommendations
![[fault announcement] one stored procedure brings down the entire database](/img/7c/e5adda73a077fe4b8f04b59d1e0e1e.jpg)
[fault announcement] one stored procedure brings down the entire database

Solution to the 39th weekly game of acwing
随机推荐
Confirm the importance of requirements at the initial stage of EDI project
Risk management - Asset Discovery series - public web asset discovery
Spirit information development log (4)
How to select cloud game platforms? Just pay attention to two points
The influence of TLS protocol and cipher on remote RDP
Easycvr is cascaded to easygbs through gb28181 protocol. Notes on video channel failure
Why migrate dig to wire
Precautions for selecting high frequency signal generator
New tea: reshuffle, transformation, merger and acquisition
How to use the domain name? What domain name should be selected to purchase
Provide SFTP connection for Amazon S3
10 year old drivers who have been engaged in software testing tell you what type of software is suitable for automation
How to register a domain name? What are the benefits of building a website?
The difference between ArrayList and LinkedList and the principle of using scene locality
WordPress applet build applet from zero to one [server configuration]
12. Tencent cloud IOT device side learning -- NTP function and Implementation
Sub process call - process arrangement in complex O & M scenarios
Basic concepts of complex networks
Analysis of DDoS attack methods
Text classification and fine tuning using transformer Bert pre training model