My Commands

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

*************************************************

Ping
**********************************************************************************

ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-
r count] [-s count] [-w timeout] [-R] [-S srcaddr] [-p]
[-4] [-6] target [/?]

The availability of certain ping command switches


and other ping command syntax might differ
from operating system to operating system.
How to Read Command Syntax
Ping Command Options
Item Explanation
-t Using this option will ping the target until you force it to stop by using Ctrl+C.
-a This ping command option will resolve, if possible, the hostname of an IP
address target.
-n count This option sets the number of ICMP Echo Requests to send, from 1 to
4294967295. The ping command will send 4 by default if -n isn't used.
-l size Use this option to set the size, in bytes, of the echo request packet from 32 to
65,527. The ping command will send a 32-byte echo request if you don't use the -
l option.
-f Use this ping command option to prevent ICMP Echo Requests from being
fragmented by routers between you and the target. The -f option is most often used
to troubleshoot Path Maximum Transmission Unit (PMTU) issues.
-i TTL This option sets the Time to Live (TTL) value, the maximum of which is 255.
-v TOS This option allows you to set a Type of Service (TOS) value. Beginning in
Windows 7, this option no longer functions but still exists for compatibility
reasons.
-r count Use this ping command option to specify the number of hops between your
computer and the target computer or device that you'd like to be recorded and
displayed. The maximum value for count is 9, so use the tracert command instead if
you're interested in viewing all the hops between two devices.
-s count Use this option to report the time, in Internet Timestamp format, that each echo
request is received and echo reply is sent. The maximum value for count is 4,
meaning that only the first four hops can be time stamped.
-w timeo Specifying a timeout value when executing the ping command adjusts the amount
ut of time, in milliseconds, that ping waits for each reply. If you don't use the -
w option, the default timeout value of 4000 is used, which is 4 seconds.
-R This option tells the ping command to trace the round trip path.
-S srcadd Use this option to specify the source address.
Ping Command Options
r
-p Use this switch to ping a Hyper-V Network Virtualization provider address.
-4 This forces the ping command to use IPv4 only but is only necessary if target is a
hostname and not an IP address.
-6 This forces the ping command to use IPv6 only but as with the -4 option, is only
necessary when pinging a hostname.
target This is the destination you wish to ping, either an IP address or a hostname.
/? Use the help switch with the ping command to show detailed help about the
command's several options.
The -f, -v, -r, -s, -j, and -k options work when
pinging IPv4 addresses only. The -R and -S options
only work with IPv6.

Other less commonly used switches for the ping


command exist including [-j host-list], [-k host-list],
and [-c compartment]. Execute ping /? from the
Command Prompt for more information on these
options.

You can save the ping command output to a


file using a redirection operator.
21 Best Command Prompt Tricks

Ping Command Examples


Below are several examples of commands that use
ping.

Ping Google.com
ping -n 5 -l 1500 www.google.com

In this example, the ping command is used to ping the


hostname www.google.com. The -n option tells the
ping command to send 5 ICMP Echo Requests
instead of the default of 4, and the -l option sets the
packet size for each request to 1500 bytes instead
of the default of 32 bytes.
The result displayed in the Command Prompt window
will look something like this:
Reply from 172.217.1.142: bytes=1500 time=30ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=30ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=29ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=30ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=31ms TTL=54
Ping statistics for 172.217.1.142:
Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 29ms, Maximum = 31ms, Average = 30ms

The 0% loss reported under Ping statistics for


74.217.1.142 explains that each ICMP Echo Request
message sent to www.google.com was returned.
This means that, as far as this network connection
goes, it can communicate with Google's website just
fine.

Ping localhost
ping 127.0.0.1

In the above example, we're pinging 127.0.0.1, also


called the IPv4 localhost IP address or IPv4 loopback
IP address, without options.

Using the ping command with this address is an


excellent way to test that Windows' network features
are working properly but it says nothing about your
own network hardware or your connection to any
other computer or device. The IPv6 version of this
test would be ping ::1.

Find Hostname With Ping


ping -a 192.168.1.22

In this example, we're asking the ping command to


find the hostname assigned to the 192.168.1.22 IP
address, but to otherwise ping it as normal.
The command might resolve the IP
address, 192.168.1.22, as the hostname J3RTY22,
for example, and then execute the remainder of the
ping with default settings.

Ping Router Command


ping 192.168.2.1

Similar to the ping command examples above, this


one is used to see if your computer can reach your
router. The only difference here is that instead of
using a ping command switch or pinging the
localhost, we're checking the connection between
the computer and the router (192.168.2.1 in this
case).

If you're having trouble logging in to your router or


accessing the internet at all, see if your router is
accessible with this ping command, of course,
replacing 192.168.2.1 with your router's IP address.

Ping With IPv6


ping -t -6 SERVER

In this example, we force the ping command to use


IPv6 with the -6 option and continue to
ping SERVER indefinitely with the -t option. You
can interrupt the ping manually with Ctrl+C.

When needed, you can run the ping command with a series of options in order to adjust the
ICMP echo request’s default value. The following table gives you an overview of the command
line’s most important options.

Option
(Choice) Description

-t With option -t, the addressed target computer is pinged until you end the procedure w
Option
(Choice) Description

Ctrl + C to display the ping statistics. This is called a continuous ping (see tip below).

-a <ip> Use the ping command with option -a and the target computer’s IP address in order t
determine the target’s host name. The computer name will be displayed to you along
the ping statistics in the terminal.

-n With the -n option, you define the desired number of ICMP echo requests. It sends fo
<number> ping requests in the default setting.

-l <size> With option -l, you define the size of the ICMP echo request in bytes. The default valu
32. Ping can be used to send data packets with a maximum size of 65,527 bytes.

-f If the ping command is run with option -f, the program sets the “Do not Fragment” flag
the ICMP echo request packet’s IP header to 1. Such a request cannot be broken up
smaller units by network nodes en route to the target. This option is only available in
networks.

-i <TTL> Use the -i option if you want a user-defined TTL for your ICMP echo request. The
maximum is 255.

-4 The -4 option forces the use of IPv4 and is only employed if the recipient is addresse
the hostname.

-6 Option -6 forces the use of IPv6 and is only employed when the recipient is addresse
the hostname.

*************************************************
Ipconfig
**********************************************************************************

 Article
 02/04/2023
 9 contributors
Feedback

Displays all current TCP/IP network configuration values and refreshes Dynamic Host
Configuration Protocol (DHCP) and Domain Name System (DNS) settings. Used
without parameters, ipconfig displays Internet Protocol version 4 (IPv4) and IPv6
addresses, subnet mask, and default gateway for all adapters.
Syntax
Copy
ipconfig [/allcompartments] [/all] [/renew [<adapter>]] [/release [<adapter>]]
[/renew6[<adapter>]] [/release6 [<adapter>]] [/flushdns] [/displaydns]
[/registerdns] [/showclassid <adapter>] [/setclassid <adapter> [<classID>]]

Parameters

Parameter Description

/all Displays the full TCP/IP configuration for all adapters. Adapters can represent
physical interfaces, such as installed network adapters, or logical interfaces, such
as dial-up connections.

/displaydns Displays the contents of the DNS client resolver cache, which includes both entries
preloaded from the local Hosts file and any recently obtained resource records for
name queries resolved by the computer. The DNS Client service uses this
information to resolve frequently queried names quickly, before querying its
configured DNS servers.

/flushdns Flushes and resets the contents of the DNS client resolver cache. During DNS
troubleshooting, you can use this procedure to discard negative cache entries
from the cache, as well as any other entries that have been added dynamically.

/registerdns Initiates manual dynamic registration for the DNS names and IP addresses that are
configured at a computer. You can use this parameter to troubleshoot a failed DNS
name registration or resolve a dynamic update problem between a client and the
DNS server without rebooting the client computer. The DNS settings in the
advanced properties of the TCP/IP protocol determine which names are registered
in DNS.

/release [<adapter>] Sends a DHCPRELEASE message to the DHCP server to release the current DHCP
configuration and discard the IP address configuration for either all adapters (if an
adapter is not specified) or for a specific adapter if the adapter parameter is
included. This parameter disables TCP/IP for adapters configured to obtain an IP
address automatically. To specify an adapter name, type the adapter name that
appears when you use ipconfig without parameters.

/release6[<adapter>] Sends a DHCPRELEASE message to the DHCPv6 server to release the current DHCP
configuration and discard the IPv6 address configuration for either all adapters (if
an adapter is not specified) or for a specific adapter if the adapter parameter is
included. This parameter disables TCP/IP for adapters configured to obtain an IP
address automatically. To specify an adapter name, type the adapter name that
appears when you use ipconfig without parameters.

/renew [<adapter>] Renews DHCP configuration for all adapters (if an adapter is not specified) or for a
specific adapter if the adapter parameter is included. This parameter is available
only on computers with adapters that are configured to obtain an IP address
Parameter Description

automatically. To specify an adapter name, type the adapter name that appears
when you use ipconfig without parameters.

/renew6 [<adapter>] Renews DHCPv6 configuration for all adapters (if an adapter is not specified) or for
a specific adapter if the adapter parameter is included. This parameter is available
only on computers with adapters that are configured to obtain an IPv6 address
automatically. To specify an adapter name, type the adapter name that appears
when you use ipconfig without parameters.

/setclassid <adapter>[<classID>] Configures the DHCP class ID for a specified adapter. To set the DHCP class ID for
all adapters, use the asterisk (*) wildcard character in place of adapter. This
parameter is available only on computers with adapters that are configured to
obtain an IP address automatically. If a DHCP class ID is not specified, the current
class ID is removed.

/showclassid <adapter> Displays the DHCP class ID for a specified adapter. To see the DHCP class ID for all
adapters, use the asterisk (*) wildcard character in place of adapter. This
parameter is available only on computers with adapters that are configured to
obtain an IP address automatically.

/? Displays Help at the command prompt.

Remarks

 This command is most useful on computers that are configured to obtain


an IP address automatically. This enables users to determine which
TCP/IP configuration values have been configured by DHCP, Automatic
Private IP Addressing (APIPA), or an alternate configuration.

 If the name you supply for adapter contains any spaces, use quotation
marks around the adapter name (for example, "adapter name").

 For adapter names, ipconfig supports the use of the asterisk (*) wildcard
character to specify either adapters with names that begin with a
specified string or adapters with names that contain a specified string.
For example, Local* matches all adapters that start with the string Local
and *Con* matches all adapters that contain the string Con.

Examples

To display the basic TCP/IP configuration for all adapters, type:

Copy
ipconfig
To display the full TCP/IP configuration for all adapters, type:

Copy
ipconfig /all

To renew a DHCP-assigned IP address configuration for only the Local Area


Connection adapter, type:

Copy
ipconfig /renew Local Area Connection

To flush the DNS resolver cache when troubleshooting DNS name resolution
problems, type:

Copy
ipconfig /flushdns

To display the DHCP class ID for all adapters with names that start with Local, type:

Copy
ipconfig /showclassid Local*

To set the DHCP class ID for the Local Area Connection adapter to TEST, type:

Copy
ipconfig /setclassid Local Area Connection TEST

ARP Commands
The ARP commands to view, display, or modify the details/information in an ARP
table/cache.

The ARP cache or table has the dynamic list of IP and MAC addresses of those
devices to which your computer has communicated recently in a local network. The
purpose of maintaining an ARP table is that when you want to communicate with
another device, your device does not need to send the ARP request for the MAC
address of that device.

The ARP commands also helps to find out the duplicate IP address and invalid entries
in an ARP table/cache.
Some ARP commands are given below:

PauseNext

Unmute

Current Time 7:09

Duration 18:10

Loaded: 44.76%
Â

Fullscreen

o arp -a: This command is used to display the ARP table for a particular IP address. It
also shows all the entries of the ARP cache or table.
o arp -g: This command works the same as the arp -a command.
o arp -d: This command is used when you want to delete an entry from the ARP table
for a particular interface. To delete an entry, write arp -d command along with the IP
address in a command prompt you want to delete.

1. Syntax: arp -d 192.168.43.255


o arp -d *: You can also delete all the entries from the ARP table. This command will
remove or flush all the entries from the table.
o arp -s: This command is used to add the static entry in the ARP table, which resolves
the InetAddr (IP address) to the EtherAddr (physical address). To add a static entry
in an ARP table, write arp -s command along with the IP address and MAC
address of the device in a command prompt.

1. Syntax: arp -s 192.168.43.160 00-aa-00-62-c6-09

Where, IP address = 192.168.43.160

MAC address = 00-aa-00-62-c6-09

o /?: This command is used to show the help at the command prompt.
o arp purge-delay: The arp purge-delay command delays the purging in the ARP
entries in an ARP table/cache when the interface goes down or slows down. When
the interface comes up within the delay time, the ARP entries are restored, and packet
loss with ECMP (Equal Cost Multipath) is restricted.
o no arp purge-delay: This command is used to turn off the purge delay.
o arp timeout: This command is used to determine how long the dynamic entries
learned on the interface resides in the ARP cache. This command is also used in the
interface configuration mode. When the timeout of an interface changes, this change
only applies to that particular interface.
o show interface: This command is used to show the ARP timeout value. The format of
the timeout value is hours: minutes: seconds.
o clear arp cache: This command deletes/removes all the dynamic entries from the
ARP table.
o proxy-arp: This command is used to enable the proxy ARP on an interface. The
network devices are able to respond to ARP requests only when the proxy ARP is
enabled.
o no proxy-arp: This command is used to disable the proxy-arp on the interface.
o show arp: This command is used to indicate the Address Resolution Protocol. ARP
creates a correspondence between network addresses and hardware addresses of
Ethernet. The record of each correspondence is stored in an ARP table for a fixed
amount of time.
o show arp traffic: This command is used to display the static traffic on the Address
Resolution Protocol (ARP).

nslookup command in Linux with Examples


mahimabadjate

 Read

 Discuss

Nslookup (stands for “Name Server Lookup”) is a useful command for getting
information from the DNS server. It is a network administration tool for querying the
Domain Name System (DNS) to obtain domain name or IP address mapping or any
other specific DNS record. It is also used to troubleshoot DNS-related problems.
Syntax:
nslookup [option]
Options of nslookup command:
 nslookup google.com :
nslookup followed by the domain name will display the “A Record” (IP
Address) of the domain. Use this command to find the address record for a
domain. It queries to domain name servers and gets the details.

 nslookup 192.168.0.10: Reverse DNS lookup


You can also do the reverse DNS look-up by providing the IP Address as an
argument to nslookup.
 nslookup -type=any google.com : Lookup for any record
We can also view all the available DNS records using the -
type=any option.

 nslookup -type=soa redhat.com : Lookup for an soa record


SOA record (start of authority), provides the authoritative information about
the domain, the e-mail address of the domain admin, the domain serial
number, etc…
 nslookup -type=ns google.com : Lookup for an ns record
NS (Name Server) record maps a domain name to a list of DNS servers
authoritative for that domain. It will output the name serves which are
associated with the given domain.

 nslookup -type=a google.com : Lookup for an a record


We can also view all the available DNS records for a particular record
using the -type=a option.
 nslookup -type=mx google.com : Lookup for an mx record
MX (Mail Exchange) record maps a domain name to a list of mail exchange
servers for that domain. The MX record tells that all the mails sent to
“google.com” should be routed to the Mail server in that domain.

 nslookup -type=txt google.com : Lookup for an txt record


TXT records are useful for multiple types of records like DKIM, SPF, etc.
You can find all TXT records configured for any domain using the below
command.

You might also like