Computer lessons

Commands for checking and correcting network settings. Learning to work with CMD: launch, configuration, commands Command line Internet

Many users do not know that Windows has a tool called the command line. It is used quite rarely and mainly by people who need advanced functionality of the system, because... The command line has in its arsenal a huge number of operators and capabilities that are not visualized.

We will not consider all commands, but will pay attention only to useful operators for working with the local network and the Internet.

Getting the network adapter configuration with ipconfig

The first command we'll look at is ipconfig. The result will be a comprehensive network connection information computer. It shows the main characteristics of all network adapters on a computer or laptop.

What parameters can be obtained using this operator:

  • To know addressWi-Fi, where you can go to the device settings. It is shown as the main gateway.
  • Can determine yourIP, if the device is connected to a local network. By the way, a computer connected to a router is also considered to be located on the local network.
  • If you connect via L2TP, PPPoE or PPTP, you can defineInternet IP, which is set in the connection properties. But it would be better to use any website to obtain such information, since the address may not always be displayed correctly.

Flushing the DNS cache - ipconfig /flushdns

If errors occur ERR_ NAME_ RESOLUTION_ FAILED or ERR_ DNS_ FAIL while working with the Internet, as well as if DNS addresses have been changed manually or automatically, you can use ipconfig /flushdns. The operator will flush the DNS cache, since Windows does not always do this itself and after changing servers, old names may be used.

ping and tracert commands

If problems with the network begin to arise, such as unstable operation, Internet outages or problems with websites, then you need to try one of the commands - ping or tracert.

The first one pings the required resource or device, i.e. will check if your computer sees it. For example, the google.com search engine does not open. Just enter ping google.com and see the result.

The screenshot shows that the site is defined and the packet transmission speed is shown. The result is how many packets were sent and how many were received back. If the resource is unavailable, then in response we receive a message that timeout exceeded. Accordingly, the result will be packet loss, which will be indicated on the command line.

Tracing performed by the tracert command allows you to completely trace the path of the package. If your site is running slow, you can find out exactly where the delay is occurring.

Checking network connections netstat –an

The netstat command is a powerful tool that allows you to find out many network parameters. One of the most useful functions is the determination of all currently used ports, connections, remote IPs. To use it, just write in the console netstat –an.

Using telnet

The telnet client must be connected before use. For this you need open control panel and go to " programs and components" It allows you to connect and work with servers without using third-party software.

Other useful network commands

Not all commands are included in the article; we chose the ones that we think are most useful to the average user. However, there are a few more operators worth mentioning:

That's all. We have considered only a small part of the command line capabilities. Many of the commands that are described in the article have additional parameters and capabilities. But we did not go into details, but considered only those that could be useful at home. The entire set of functions will be useful only to highly specialized specialists.

Don't worry if you've never used the command line before. It's pretty simple. We will tell you everything you need to start using it. Below you will find some of the most important commands for setting up your home network.

1. PING

PING is one of the basic and most useful CMD commands. It displays the quality of the connection, showing whether your computer can send data to the target IP address, and if so, at what speed.

Here is an example of using the command:

The command operates on the following principle: it sends a certain number of data packets and determines how many of them came back. If some of them have not returned, she reports the loss. Packet loss leads to poor performance in games and Internet broadcasts. This is a great way to test your internet connection.

By default, the command sends four packets with a timeout of four seconds for each. You can increase the number of packets like this: ping www.google.com -n 10

You can also increase the timeout duration (the value is displayed in milliseconds): ping www.google.com -w 6000

2. TRACERT

TRACERT stands for Trace Route. Like PING, the command sends a data packet to resolve network problems. However, it does not determine the speed of sending and returning a packet, but its route.

Usage example:

The command displays a list of all routers through which data passes on the way to the destination node. Why do we see three durations for each router? Because TRACERT sends three data packets in case one of the routers gets lost or takes too long for some reason.

3.PATHPING

The PATHPING command is similar to TRACERT, but it is more informative and therefore requires more time to execute. It analyzes the route of data packets and determines at which intermediate nodes the loss occurred.

Usage example:

4.IPCONFIG

This command is most commonly used to debug networks in Windows. And it's not just the amount of information it provides, but also the fact that it is combined with several keys to execute specific commands.

Usage example:

When entered without keys, IPCONFIG reflects all the network adapters on your computer and how they work. IPv4 Addresses and Default Gateway contain the most important information.

To flush the DNS cache, use the following key: ipconfig /flushdns

This operation may help if the Internet is working, but you cannot access some sites or servers.

5.GETMAC

Each IEEE 802 compliant device has a unique MAC (Media Access Control) address. The manufacturer assigns each piece of equipment its own address, which is written in the device itself.

Usage example:

You may see multiple MAC addresses depending on how many network adapters are installed on your computer. For example, Wi-Fi and Ethernet internet connections will have separate MAC addresses.

6. NSLOOKUP

NSLOOKUP stands for Name Server Lookup. The potential of this utility is huge, but most people don't need it. For ordinary users, all that is important is the ability to determine the IP address of a domain name.

Usage example:

Keep in mind that some domains are not tied to a single IP address, which means you will receive a different address each time you enter the command. This is quite normal for large sites because they are loaded from a huge number of computers.

If you want to convert an IP address to a domain name, simply enter it into your browser and you will see where it leads. However, not all IP addresses lead to domain names. Many of them cannot be reached through a web browser.

7. NETSTAT

This utility is a tool for collecting statistics, analysis and diagnostics. It is quite complex if you use its full potential (for example, setting up a local enterprise network).

Usage example:

By default, the command shows all active connections on your system. An active connection does not mean that data is being exchanged. It only indicates that a port is open somewhere and the device is ready to connect.

The command also has several switches that change the type of information displayed. For example, the key -r will display routing tables.

8.NETSH

NETSH stands for Network Shell. This command allows you to configure almost any network adapter on your computer in more detail.

When you enter NETSH, the command prompt enters shell mode. There are several contexts inside it (routing, DHCP-related commands, diagnostics).

You can see all contexts as follows:

And you can see all the commands within one context like this:

You can dig deeper and see a list of all subcommands within a single command:

For example, you can enter the following command to see all the network drivers and their characteristics on your system: netsh wlan show drivers

Keep in mind that if you really want to get serious about configuring your network through the command line, you'll have to master this command.

Any system administrator is faced with setting up network interfaces. Most people use the Windows graphical interface for this purpose, which is not always convenient. In this article I will tell you how to set up a network using the cmd command line interface using the built-in netsh utility.

Windows operating systems have a special netsh utility for configuring a network adapter from the cmd command line.

netsh.exe (network shell) is a network shell (program) for Windows OS that allows you to configure network parameters, including remotely. This utility is available on all versions of Windows starting from Windows 2000.

Run command line:

Start -> Run -> enter cmd.exe in the line

A black window with a blinking cursor will open. Here we will enter the commands listed below (well, this is for those who have never worked with the command line).

Setting the IP address, mask and gateway.

netsh interface ip set address name="Local Area Connection" static 192.168.1.15 255.255.255.0 192.168.1.1

Where
Local Area Connection - the name of your network interface.
192.168.1.15 — network address (ip address).
255.255.255.0 — network mask.
192.168.1.1 - gateway (default gateway).

Setting an additional IP address.

netsh interface ip add address name="Local Area Connection" 192.168.1.20 255.255.255.0

Enable automatic acquisition of IP address, netmask and gateway from the DHCP server.

netsh interface ip set address "Local Area Connection" dhcp

Configuring DNS and WINS servers.

Add your preferred DNS server.

netsh interface ip set dns "Local Area Connection" static 8.8.8.8

Add an alternative DNS server.

netsh interface ip add dns "Local Area Connection" 8.8.4.4

Add a 3rd DNS server.

netsh interface ip add dns "Local Area Connection" 192.168.1.30 index=3

Setting to automatically obtain the preferred and alternative DNS server from the DHCP server.

netsh interface ip set dns "Local Area Connection" dhcp

Installing WINS.

netsh interface ip set wins "Local Area Connection" static 192.168.1.240

Enabling and disabling network interfaces.

Disabling the interface

netsh interface set interface name="Local Area Connection" admin=DISABLED

Enabling the Interface

netsh interface set interface name="Local Area Connection" admin=ENABLED

View network settings.

Extended network interface configuration output.

View interface status (connected/disconnected).

C:\Windows\System32>netsh interface ip show interface Ind Met MTU Status Name — ———- ———- ———— ————————— 1 50 4294967295 connected Loopback Pseudo-Interface 1 12 10 1300 disconnected Local Area Connection

View the routing table.

netsh interface ip show route

View IP address configuration.

netsh interface ip show addresses

View DNS server addresses.

netsh interface ip show dnsservers

View WINS server addresses.

netsh interface ip show winsservers

Saving and restoring the configuration of network interfaces.

Well, now the most interesting part. Let's talk about how to save network settings as a configuration file and restore from a configuration file. This may be useful for those who constantly change network settings.

C:\Windows\System32>netsh -c interface dump > C:\my-config.txt

Restore network settings from a configuration file.

C:\Windows\System32>netsh -f C:\my-config.txt

That's all. We have not considered all the features of the Netsh.exe utility, but only the most frequently used ones. Using the Windows command line and the netsh utility you can make your life much easier.

Network setup via command line and BAT file.

This article will look at options for setting up and changing the network details for a local network connection via the command line (CMD) and a BAT file.

Option #1:

Changing network settings via the command line. Click “Start” - “Run” or press the key combination Win + R. The “Run” window will open. In the line, enter “cmd” (without quotes) and click the “OK” button. A cmd.exe window will open. Enter the commands:

Command to change the IP address, subnet mask, default gateway and interface metrics. Change “Local Area Connection” to the name of your network connection. 192.168.0.100 is the IP address, 255.255.255.0 is the subnet mask, 192.168.0.1 is the gateway, the unit (1) following the gateway (192.168.0.1) is the interface metric.

Copy code

Command to change DNS servers. The first line of code changes/specifies the preferred DNS server, and the second line of code changes/specifies the alternative DNS server.

CMD

Copy code

Option #2:

Changing network settings via BAT file. Create a text document, open it, click the “File” button, select “Save As”. A file saving window will open. In the “File Type” menu, select “All Files” (the default will be “Text Document”), select ANSI encoding (if changed to another). Next, add “.bat” to the file name, so you should get something like the following file name: “Text document.bat”. Click the “Save” button. Next, you can change the file name to your own. Now right-click on the bat file and select “Edit” from the menu. Enter the following commands into the window:

BATCH

Copy code

The "chcp 1251" command sets the encoding. If this is not done, then through the BAT file it will not be possible to change the settings on a network interface with a name consisting of Russian characters.

Example BAT file:

When you run this batch file, you will be asked to choose one of two setup options - home or work. In the code example, we change the name of the network connection to our own, if it is different from the default, i.e. "LAN connection". I also change the network settings - IP, mask, gateway and DNS server. After changing the network settings, you will be prompted to view the current network settings (ipconfig /all command). We answer yes or no depending on whether you need it or not.

BATCH

Copy code

This is what the window of this batch file will look like when launched.


Rice. 1

View current configuration:

netsh interface ip show config

Exporting configuration commands to a netsh script:

netsh -c interface ip dump > c:\if-ip-dump.txt

Importing the netsh configuration script into the system:

netsh -f c:\if-ip-dump.txt

Interface configuration via:

netsh interface ip set address "Local Area Connection" dhcp netsh interface ip set dns "Local Area Connection" dhcp

Static interface configuration:

netsh interface ip set address "Local Area Connection" static ipaddr subnetmask gateway metric

netsh interface ip set address "Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1 netsh interface ip set dns "Local Area Connection" static 192.168.0.1 netsh interface ip set wins "Local Area Connection" static 192.168.0.2

Adding and removing an additional IP address:

netsh interface ip add address "Local Area Connection" 192.168.0.200 255.255.255.0 netsh interface ip del address "Local Area Connection" 192.168.0.200

Removing the main server:

netsh interface ip del dns "Local Area Connection" 192.168.0.1

Adding and removing an additional server:

netsh interface ip add dns "Local Area Connection" 192.168.0.2 index=2 netsh interface ip del dns "Local Area Connection" 192.168.0.2

Windows DLL files
This section contains an archive of dll files. You can download netsh.exe for free.

Instructions for registering DLL files in Windows 8

Instructions for registering DLL files in Windows 98, XP, Vista, 7:
If you have errors related to *.dll and *.ocx files, you must:

Commands to check and fix network settings

Check if the required files are present on the system. The *.dll and *.ocx files, as a rule, should be located in the system folder C:\WINDOWS\system32.
If files are present, you need to register them.
— Click on “Start/Run” or press the key combination Win + R
or

— Enter regsvr32 netsh.exe (for example: regsvr32 netsh.exe)

- To restart a computer
2. If the required files are not there, then look for them on the website, download and copy to the C:\WINDOWS\system32 folder and register as indicated in the first paragraph. ABCDEFGHIJKLMNOPQRSTUVWXYZ

If you receive an error message that netsh.exe is missing, damaged, lost, or Microsoft Corporation, Network Command Shell, 32 bits " The program cannot be started because netsh.exe is missing from the computer«, « netsh.exe was not found» (« netsh.exe not found"), then download the netsh.exe file and copy it to the “c:/windows/system32” folder (if Windows is installed on drive C). Then restart your computer.

21.3K

Why is there such chaos in the world? Yes, because the administrator of our system forgot to fulfill his duties. Or I just lost the list of cmd commands from our world. Although this is a somewhat original look at the existing order of things, it nevertheless reflects part of the truth we need: using the command line, you can easily bring order to your computer:

What is the command line

The command line is the simplest tool for managing your computer's operating system. Control occurs using a number of reserved commands and a set of text keyboard characters without the use of a mouse ( in the Windows operating system).

On UNIX-based systems, you can use the mouse when working with the command line.

Some commands came to us from MS-DOS. The command line is also called the console. It is used not only to administer the operating system, but also to manage common programs. Most often, the most rarely used commands are included in this set of commands.

The advantage of using cmd basic commands is that it consumes a minimal amount of system resources. And this is important in emergency situations when all the computer’s powers are, one way or another, involved.

cmd implements the ability to execute and create entire batch files, which represent a specific order of execution of a number of commands (scripts). Thanks to this, they can be used to automate certain tasks ( account management, data archiving and more).

The Windows command shell for manipulating and redirecting commands to certain operating system utilities and tools is the Cmd.exe interpreter. It loads the console and redirects commands in a format that the system understands.

Working with the command line in the Windows operating system

You can call the console in Windows in several ways:

Both methods involve running the console as the current user. That is, with all the rights and restrictions that are imposed on its role in the operating system. To run cmd with administrator rights, you need to select the program icon in the Start menu and select the appropriate item in the context menu:


After launching the utility, you can get help information about commands and the format for writing them in the console. To do this, enter the help statement and press “Enter”:

Basic commands for working with files and directories

The most frequently used commands are:

  • RENAME – renaming directories and files. Command syntax:

RENAME | REN [drive/path] original file/directory name | final filename
Example: RENAME C:UsershomeDesktoptost.txt test.txt

  • DEL (ERASE) – used to delete files only, not directories. Its syntax is:

DEL | ERASE [processing method] [filename]
Example: Del C:UsershomeDesktoptest.txt/P

By processing method we mean a special flag that allows you to implement a certain condition when deleting a file. In our example, the “P” flag enables the display of a permission dialog for deleting each file:


More information about the possible values ​​of the “processing method” parameter can be found in the technical documentation for the Windows operating system.

  • MD – allows you to create a folder at the specified path. Syntax:

MD [drive:] [path]
Example:
MD C:UsershomeDesktoptest1test2

The example will create a subfolder test2 within the test1 folder. If one of the path's root folders does not exist, it will be created too:

  • RD ( RMDIR) – deleting a specific folder or all directories at a specified path. Syntax:

RD | RMDIR [process_key] [drive/path]
Example:
rmdir /s C:UsershomeDesktoptest1test2

The example uses the s flag, which will cause the entire branch of directories specified in the path to be deleted. Therefore, you should not use the rmdir command unnecessarily with this processing key.

In the next section, we'll take a closer look at network cmd commands.

Commands for working with the network

The command line allows you to manage not only the PC file system, but also its network capabilities. The console's network commands include a large number of operators to monitor and test the network. The most relevant of them are:

  • ping – the command is used to monitor the network connection capabilities of a PC. A set number of packets are sent to the remote computer and then sent back to them. The transmission time of packets and the percentage of losses are taken into account. Syntax:

ping [-t] [-a] [-n counter] [-l size] [-f] [-i TTL] [-v type] [-r counter] [-s counter] [(-j host_list | - k node_list)] [-w interval] [target_PC_name]

Example command implementation:
ping example.microsoft.com
ping –w 10000 192.168.239.132

In the last example of the cmd ping command, the request is sent to the recipient with the specified IP address. The waiting interval between packets is 10,000 (10 seconds). By default this parameter is set to 4000:

  • tracert – used to determine the network path to a specified resource by sending a special echo message through the protocol
  • ICMP (Control Message Protocol). After running the command with parameters, a list of all routers through which the message passes is displayed. The first element in the list is the first router on the side of the requested resource.

Syntax of tracer cmd command:
tracert [-d] [-h maximum_hop_number] [-j node_list] [-w interval] [target_resource_name]
Example implementation:
tracert -d -h 10 microsoft.com

The example traces the route to a specified resource. This increases the speed of the operation due to the use of the d parameter, which prevents the command from attempting to obtain permission to read IP addresses. The number of transitions (jumps) is limited to 10 using the set value of the h parameter. By default, the number of jumps is 30:

shutdown [(-l|-s|-r|-a)] [-f] [-m [\PC_name]] [-t xx] [-c “messages”] [-d[u][p]: xx:yy]
Example:
shutdown /s /t 60 /f /l /m \191.162.1.53

The remote PC (m) with the specified IP address (191.162.1.53) will shut down (s) after 60 seconds (t). This will force you to log out of all applications (f) and the current user's session (l).

A few more necessary commands

When working with a PC, a few more commands from the huge list of cmd operators may come in handy. Here are some of them:

  • format – formats a CD in the drive whose name is specified in the parameters. Command syntax:

format volume

When writing the syntax of a command, square brackets highlight optional parameters.

This is confirmed by the following command example:
format e : - the media in drive E will be formatted;

  • set – used to work with environment variables. This cmd command allows you to create, delete and assign a value to variables that can be used while working with the command line. Syntax:

set [] ] string]
Example:
set include=c:inc

  • start – designed to launch the specified program or command in a separate window:

Example:
start notepad


Now, with the knowledge you have gained, you can not only control your computer, but also control the whole reality. All that remains is to launch the corresponding cmd instance. And not all commands described in the article may be suitable for managing “ a valid copy"of our reality.

I have already written about what it is and how to check under what address the outside world sees you. However, often this information is not enough to understand what address is assigned to your network card, as well as to diagnose connection problems. I will give a list of commands that can be used. (you can also read about visual customization on my website)

First you need to open the command line. This is done like this: press the start button, select “run”.

An alternative method is to press the Win key (between Ctrl and Alt) and R at the same time, this method also works on Vista

A window appears in which you need to enter cmd and click OK

The same command line appears

In it you can type and “enter” commands by pressing Enter. The results can be copied - if you press the right button, you can select the desired piece, then you need to press the right mouse button again.

ping command

The first team you need to get to know is ping, which checks the availability of a given address. Enter the command ping 127.0.0.1. It should look something like this (if the command is not ping does not work, then perhaps the instructions for fixing the cmd no command error will help solve the problem):

C:\Documents and Settings\Administrator>ping 127.0.0.1

Exchange of packets from 127.0.0.1 to 32 bytes:

Response from 127.0.0.1: number of bytes=32 time

Response from 127.0.0.1: number of bytes=32 time

Response from 127.0.0.1: number of bytes=32 time

Ping statistics for 127.0.0.1:

Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\Documents and Settings\Administrator>

As we can see, 4 packets were sent to address 127.0.0.1, and they all reached the target. What kind of address was this and why was I sure that the packages would arrive? The answer is simple - the packages were not sent anywhere, but remained on your computer. This address is specific and is used for loopback packets that do not go anywhere outside. Great, we can now “ping” the address of this site: 212.193.236.38

C:\Documents and Settings\Administrator>ping 212.193.236.38

Exchange of packets from 212.193.236.38 to 32 bytes:

Reply from 212.193.236.38: number of bytes=32 time=3ms TTL=55

Reply from 212.193.236.38: number of bytes=32 time=3ms TTL=55

Reply from 212.193.236.38: number of bytes=32 time=3ms TTL=55

Ping statistics for 212.193.236.38:

Packets: sent = 4, received = 4, lost = 0 (0% loss),

Approximate round trip time in ms:

Minimum = 3ms, Maximum = 3ms, Average = 3ms

C:\Documents and Settings\Administrator>

You can notice only one difference - the packets did not arrive instantly, but in 3 milliseconds. I hope you also didn’t experience any delay in delivering packages, and most importantly, you didn’t see a line like

Timed out request.

The appearance of such lines means that some packets are lost. This indicates problems with the line or server you are accessing.

ipconfig command

The next important command is ipconfig. Enter it. I got it like this:

Ethernet - Ethernet adapter:

C:\Documents and Settings\Administrator>

In this case, the address turned out to be 192.168.17.139. You can also ping this address (you ping yours) - packets should arrive instantly. The default gateway is the address to which a computer sends packets when it does not find a suitable address on its network. So, in my case, all packets except those on 192.168.17.* will be sent to 192.168.17.240, and that computer must decide what to do with them and where to forward them next. Note: the local network, that is, those addresses to which packets are not sent to the gateway, is determined using a mask - the zero in the last place and 255 in all previous ones just means that the last number in the IP address can be arbitrary.

One of the standard steps when troubleshooting connection problems is to ping your gateway. If the packets do not reach it, then, apparently, the problem is somewhere nearby, for example, the power cord is damaged or poorly connected. It’s also worth knowing where the computer with your main gateway is physically located - at the provider, somewhere in the house, or maybe it’s in your apartment. Note: Some computers are configured not to respond to ping requests. Therefore, the absence of ping is not a 100% guarantee that there will be no connection with the address.

More detailed information can be obtained with the command ipconfig /all. I managed:

C:\Documents and Settings\Administrator>ipconfig /all

Setting up the IP protocol for Windows

Computer name. . . . . . . . . : sander

Primary DNS suffix. . . . . . : MSHOME

Node type. . . . . . . . . . . . . : mixed

IP routing is enabled. . . . : No

WINS proxy is enabled. . . . . . . : No

Order in which DNS suffixes are viewed. : MSHOME

Ethernet - Ethernet adapter:

The DNS suffix of this connection. . : srcc.msu.ru

Description. . . . . . . . . . . . : Broadcom 440x 10/100 Integrated Controller

Physical adress. . . . . . . . . : 00-16-D4-63-03-65

dhcp is enabled. . . . . . . . . . . : Yes

Auto-tuning is enabled. . . . . : Yes

IP address. . . . . . . . . . . . : 192.168.17.139

Subnet mask. . . . . . . . . . : 255.255.255.0

Main gate. . . . . . . . . . : 192.168.17.240

DHCP server. . . . . . . . . . . : 192.168.17.240

DNS servers. . . . . . . . . . . : 212.192.244.2

212.192.244.3

C:\Documents and Settings\Administrator>

I have highlighted the most useful information in bold. allocated me a dynamic address based on my MAC address or physical address. Mine are 212.192.244.2 and 212.192.244.3.

Other commands

Team tracert allows you to trace the path of packets from your computer to the target. Try, for example, tracing the path to this site: tracert website. The lines in the trace output are the points through which the packet passes on its path. The first point will be your gateway. Using the tracert command allows you to find the source of problems when communicating with any address. Packets sent by the tracert command have a TTL - time to live - positive integer. Each router on the path decreases this indicator by 1, if the TTL drops to zero, then the trace ends. By default, an initial TTL of 30 is used; you can set a different value with the option -h.