1. Viewing and Manipulating TCP/IP Configuration with ipconfig
The ipconfig
command is a useful command you can use to view and manipulate TCP/IP
configuration information. The most common way to use it is to view the
TCP/IP configuration data for a system. You can do so with this command:
or
The following table shows some of the output you’ll see.
Basic ipconfig Output | Comments |
---|
C:\>ipconfig Windows IP Configuration
| ipconfig
without any switches gives basic TCP/IP configuration data for each
network interface card (NIC). This example shows two NICs named Local
Area Connection and Local Area Connection 2. | Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : IPv4 Address. . . . . . . . . . . : 192.168.1.10 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . : 192.168.1.1
| This output shows the actual IP address, subnet mask, and default gateway assigned to the NIC. | Ethernet adapter Local Area Connection 2: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :
| If
a NIC is disconnected at the computer or the network device (such as a
switch), or the cable is broken anywhere in between, it shows Media
Disconnected. |
ipconfig /all shows much more detailed information, as shown in the following table.
Output of ipconfig /all | Comments |
---|
C:\>ipconfig /all Windows IP Configuration
Host Name . . . . . . . . . . . . : DC1 Primary Dns Suffix . . . . . . : Pearson.pub Node Type . . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . : No WINS Proxy Enabled. . . . . . : No DNS Suffix Search List. . . . . : Pearson.pub
| It starts with global information for the system, which applies to all NICs.
The Host Name is the name of the computer. If the
computer is joined to a domain, it is indicated in the Primary DNS
Suffix. This is blank for workgroup computers.
The Node Type indicates how NetBIOS names are
resolved. Hybrid indicates a WINS server is queried first (if
configured) and then it broadcasts. It can also be Mixed, indicating it
is broadcast first and then queries WINS. Broadcast indicates it
broadcasts only, and Peer-to-peer indicates it queries only a WINS
server.
It’s not common to enable IP routing or a WINS proxy on a Windows 7
computer, so these are almost always No. If you want host names to
search additional suffixes beyond the primary DNS suffix (such as
training.pearson.pub), they can be added and will show in the DNS
Suffix Search List. | Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . : Intel 21140-Based PCI Fast Ethernet Adapter Physical Address. . . . . . . : 00-03-FF-9C-02-00 DHCP Enabled. . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::41f0:f763:5451:198a%10(Preferred) IPv4 Address. . . . : 192.168.1.122(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DNS Servers . . . . . . . . . . . : 192.168.1.10 NetBIOS over Tcpip. . . . . . . . : Enabled
| Each
NIC has specific information starting with the name. The default name
of the first NIC is Local Area Connection, but you can change the name
of the NICs. It lists the brand and model of the NIC as a Description.
Physical Address is the MAC or Ethernet address.
When the IP address is statically assigned, DHCP
Enabled is No. Autoconfiguration refers to Automatic Private IP
Addressing (APIPA). When Autoconfiguration Enabled is set to Yes, APIPA
automatically assigns an IP address in the range of 169.254.y.z to a
DHCP client if the DHCP server doesn’t respond. It doesn’t have any
effect for non-DHCP clients or clients with a statically assigned IP
address.
If a static IPv6 address isn’t assigned, a link-local address (with a prefix of fe80) is automatically assigned.
Note
IPv6 has been included in Windows systems since Windows XP SP2. It is
installed and enabled by default in Windows Server 2008 and Windows
Server 2008 R2.
The default gateway must be on the same subnet. If you’re
having problems with name resolution, you can ping the IP address of
the DNS server as a check. |
In addition to the /all
switch, you can use several additional switches with ipconfig. The
following table lists some of the switches commonly used with ipconfig.
ipconfig Switches | Comments |
---|
/release ipconfig /release [adapter] C:\>ipconfig /release C:\>ipconfig /release "local area connection" C:\>ipconfig /release local*
| Releases
the DHCP lease for the specified adapters that have DHCP leases. If you
leave the adapter blank, it attempts to release the DHCP lease for all
adapters that have DHCP leases.
You can use the entire name of the connection or use wildcards. local* represents all connections that start with local. | /release6 ipconfig /release6 [adapter] C:\>ipconfig /release6 C:\>ipconfig /release6 "local area connection" C:\>ipconfig /release6 local*
| The /release6 switch works the same way as /release, but only for IPv6 addresses. | /renew ipconfig /renew [adapter] C:\>ipconfig /renew C:\>ipconfig /renew "local area connection" C:\>ipconfig /renew local*
| You can renew DHCP leases with the /renew
switch. It attempts to reach a DHCP server and obtain a new DHCP lease
or renew the existing lease. The lease includes an IP address and
subnet mask at a minimum but also includes other data, such as the
default gateway, the address of DNS, and the domain name. You can
identify the adapter the same way you can with the /release switch. | /renew6 ipconfig /renew6 [adapter] C:\>ipconfig /renew6 "local area connection" C:\>ipconfig /renew6 local*
| The /renew6 switch works the same way as /renew but for IPv6 addresses. | /displaydns C:\>ipconfig /displaydns
| The
DNS cache, or host cache, shows names that have been resolved by DNS
and items that are in the Hosts file. You can view the cache with the /displaydns
switch.
Items in the cache stay in it until the Time To Live (TTL) times out.
The TTL value is shown in seconds and is provided by DNS when the name
is resolved to an IP address.
Note
Items in the Hosts file (%windir%\System32\Drivers\etc\hosts) are automatically placed in the cache.
| Using /displaydns C:\>ping dc1 pinging dc1.pearson.pub [192.168.1.10] with 32 bytes of data: Reply from 192.168.1.10: bytes=32 time<1ms TTL=128 Reply from 192.168.1.10: bytes=32 time<1ms TTL=128 Reply from 192.168.1.10: bytes=32 time<1ms TTL=128 Reply from 192.168.1.10: bytes=32 time<1ms TTL=128 ping statistics for 192.168.1.10: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\>ping dc77 Ping request could not find host dc77. Please check the name and try again. C:\>ipconfig /displaydns dc1.pearson.pub ---------------------------- ------------ Record Name . . . . . : dc1. pearson.pub Record Type . . . . . : 1 Time To Live . . . . : 3581 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 192.168.1.10
Dc77 --------------------------- ------------- Name does not exist.
| In this example, DC1 is pinged in the pearson.pub domain.
The first line shows that it was successfully
resolved to 192.168.1.10 (underlined for emphasis), and then ping sends
four echo requests and receives four Echo replies.
Note
The next section covers ping in more detail if you need some reminders of what it does.
DC77 is also pinged, but the DNS server doesn’t have a record of DC77 and responds with a negative response (underlined).
With some data in the DNS resolver cache, you can
now view the cache. Notice that both DC1 and DC99 are in cache, but DC1
has an IP address and DC99 simply states that the name doesn’t exist.
Both entries came from DNS.
A TTL of 3581 is close to 60 minutes (3581 seconds
divided by 60 = 59.6 minutes). This TTL continuously counts down until
it reaches zero, and then it is automatically dropped from cache.
If the data is in cache, DNS is not queried again.
In other words, if DC1 and DC99 are pinged again, the ping uses the
data from cache.
Negative responses stay in cache for 15 minutes unless flushed out of cache using the ipconfig /flushdns command. | /flushdns C:\>ipconfig /flushdns
| There
are times when you will want to remove data from cache without waiting
for the TTL to expire. For example, if there is a negative cache entry
in cache because DNS doesn’t have a record for the client, you can
purge the DNS cache with the /flushdns switch. This also purges any entries that haven’t timed out.
Note
Items in the Hosts file (%windir%\system32\drivers\etc\hosts) are not purged when you use the /flushdns switch. The only way to remove these items from cache is to remove them from the Hosts file.
| /registerdns C:\>ipconfig /registerdns
| The /registerdns
switch initiates manual dynamic registration for the DNS names and IP
addresses that are configured at a computer. Dynamic DNS (DDNS) is used
in Microsoft domains to dynamically create and update records on DNS
servers, and it normally occurs when a computer boots. You can use this
switch 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. |
If you want to see the effect of adding entries in the hosts file, you can do so with the following steps.
Steps to Modify Hosts File | Comments |
---|
1. Launch Notepad with elevated permissions. | Click Start, type Notepad in the Start Search text box, right-click Notepad, and select Run As Administrator. If prompted by UAC to continue, click Yes. | 2. Browse to the Hosts file and open it. | Click File, Open. Browse to the %windir%\system32\drivers\etc\ folder. Change Text Documents (*.txt) to All Files in the Open dialog box. Select the hosts file and click Open. | 3. Add a bogus record after the last line in the Hosts file. | Scroll to the bottom of the file and enter the following line: | | 192.168.1.2 | DC77 | 4. Save the Hosts file. | Select File, Save to save the file.
Note
If you didn’t launch Notepad with administrative permissions, you cannot save the file.
| 5. View the cache entry with ipconfig /displaydns. | Launch a command prompt and enter ipconfig /displaydns to view the entry. | 6. Try to purge the hosts file entry. | Enter ipconfig /flushdns to purge all entries. Type ipconfig /displaydns to verify the Hosts entry remains. | 7. Ping DC77 to show that it can be resolved. | Type ping dc77 and press Enter.
In the first line, you’ll see that the ping successfully resolves it to
192.168.1.2. The echoes fail because creating a record in the hosts
file doesn’t actually create a server, but this does verify that the
hosts file provides name resolution. | 8. Return the Hosts file to normal. | Return to Notepad. Delete the line you added (192.168.1.2 DC77).
Select File, Save to save the file. Close Notepad. |
|