How to clear the DNS cache in Windows

In the Windows DNS cache, records of domain names with their IP addresses to which were accessed are stored. When a user opens a site for the first time, a DNS server is accessed; upon subsequent openings of a site, Windows already takes information from the cache. Therefore, if a new IP address has been assigned to a domain, then the system will access the old one for a while based on the data in the cache.

Continue reading “How to clear the DNS cache in Windows”

View and configure sharing of files and folders Windows from the command line

I will give an example of some commands for setting up sharing of resources.

View shared resources:

net share

Deleting a shared resource:

net share <sharename> /delete

Sharing a folder:

net share sharename=C:\dir

Example of disconnecting users from the share:

net session \\pc1 /delete

To close an open network file, use the command:

net file file_id /close

An example of granting user rights to a file (N – not set, W – write, C – change, F – full access):

cacls file.txt /G User:w

To cancel user access to a share:

cacls /R User

We allow up to 5 users to simultaneously connect to a shared resource:

net share sharename /users:5

Example of caching settings from a share (manual/BranchCache/documents/programs/none):

net share myshare /cache:manual

I want to note that when opening a share to a resource in the firewall, the following ports should be opened: TCP 139, TCP 445, UDP 137, UDP 138.

See also my articles:
Installing and using the nbtscan network scanner
Some information about the virus encryptor Trojan.Encoder.12544 attacked 06/27/2017

Setting up a network in Windows via the command line

To begin, open the command line by clicking on the shortcut in the Start menu or typing the command “cmd” in the “Run” line.

Here is an example of viewing the current configuration:

netsh interface ip show config

View a list of network interfaces:

netsh interface ipv4 show interfaces

An example of configuring static parameters for an interface named Ethernet 2:

netsh interface ip set address name="Ethernet 2" static 192.168.0.101 255.255.255.0 192.168.0.1 1

Or so:

netsh interface ipv4 set address name="Ethernet 2" source=static address=192.168.1.2 mask=255.255.255.0 gateway=192.168.1.1
netsh interface ipv4 add dnsserver name="Local" address=8.8.8.8 index=1

Example of obtaining parameters for the Ethernet 2 interface by DHCP:

netsh interface ip set address name="Ethernet 2" dhcp

Example of obtaining the DNS parameters for the Ethernet 2 interface by DHCP:

netsh interface ip set dns "Ethernet 2" dhcp

Export the current configuration to a file:

netsh -c interface dump > d:cfg1.txt

Importing a configuration from a file:

netsh -f d:cfg1.txt

How to add a Windows user from the command line

It took one day to add a user to Windows 10 from the command line, because nothing happened when the add button was pressed from the control panel.

The first step is to start the command prompt as administrator, for this, in the start menu, type “cmd” or simply find the shortcut “Command line” and click on it with the right mouse button select “Run as administrator “.

At the command prompt, execute the add user command (where NAME is the user name):

net user NAME /add

Finish, the new user can already be seen in the “Control Panel\User Accounts\User Accounts\Account Management