Hack 53 Troubleshooting Network Connections with netsh, netstat, and ipconfig More command-line tools for tracking down problems with your network connection . In addition to well-known command-line network utilities such as ping , tracert ,and pathping , there are several other all-purpose utilities that can help you troubleshoot network connections: netsh , netstat , and ipconfig . 5.13.1 Use netsh to Troubleshoot Network and Internet Connectionsnetsh is a wide- ranging command-line diagnostic tool that has an exceedingly large number of commands available. (For a complete list of available commands, use Windows XP Help and Support and search for netsh .) Here you'll learn the most interesting. Perhaps the most useful of the netsh commands are the netsh diag commands. Use them to find out information about your PC's network setup, such as finding the IP address of its mail server, newsgroup server, DNS server, and similar resources. There are two ways to use netsh : directly from the command line with all its switches, or first getting to the netsh console by typing netsh at the command line and then typing the command from the netsh> prompt that appears. For example, you could type netsh diag show adapter at the command line, which lists every network adapter on your PC, or you could get to the netsh> prompt and type diag show adapter . Use the netsh command to connect to the resources and then get information about them. For example, to find out the IP address of your DNS servers, type netsh diag show dns ; to find out the IP address of your mail server, type netsh diag connect mail . Table 5-7 list the most useful of the netsh diag commands. Precede each of them with netsh diag . Note that they each have many switches associated with them. For more details, use Windows XP Help and Support and search for netsh . Table 5-7. Useful netsh diag commands
5.13.2 Use netstat to Get Information About Open Network ConnectionsIf you want to get a snapshot of all incoming and outgoing network connections, use the netstat command. At a command prompt, type netstat . It lists all connections, including the protocol being used, the local and Internet addresses, and the current state of the connection, like this: Active Connections Proto Local Address Foreign Address State TCP PrestonGralla:1031 localhost:2929 ESTABLISHED TCP PrestonGralla:2887 192.168.1.103:netbios-ssn TIME_WAIT TCP PrestonGralla:2899 www.oreillynet.com:http ESTABLISHED TCP PrestonGralla:2900 www.oreillynet.com:http ESTABLISHED TCP PrestonGralla:2932 mail.attbi.com:pop3 ESTABLISHED TCP PrestonGralla:2936 vmms2.verisignmail.com:pop3 ESTABLISHED It will help you know whether connections are live, the network or Internet device to which they're connected, and which local resource is making the connection. It's best suited for when you're troubleshooting network problems and want to find out whether certain ports are open, why certain computers on the network are having connection problems, and similar issues. You can use command-line switches with netstat . For example, display open ports and open connections with this syntax: netstat -a . Table 5-8 lists netstat switches. Table 5-8. Netstat switches
5.13.3 Use IPConfig to Troubleshoot TCP/IPOne of the most powerful tools for analyzing and troubleshooting TCP/IP problems is the ipconfig command-line utility. It provides information about each of your adapters, including the assigned IP address, subnet mask, default gateway, MAC address, DNS servers, whether DHCP is enabled, and a variety of other data. To see basic information about your adapters, type ipconfig at a command prompt, and you'll see information like this: Windows IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : ne1.client2.attbi.com IP Address. . . . . . . . . . . . : 192.168.1.100 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 PPP adapter {6A724E76-AB59-4ABC-BBF5-41CA4410EB8D}: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 172.165.155.106 Subnet Mask . . . . . . . . . . . : 255.255.255.255 Default Gateway . . . . . . . . . : As you can see, ipconfig provides basic information about your IP address, subnet mask, default gateway, and a connection-specific DNS suffix, if any. However, you can get much more detailed information by using the /all switch, like this: ipconfig /all . For most troubleshooting purposes, use the /all switch. You get a much more comprehensive listing, as shown here: Windows IP Configuration Host Name . . . . . . . . . . . . : PrestonGralla Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : ne1.client2.attbi.com Description . . . . . . . . . . . : CNet PRO200WL PCI Fast Ethernet Adapter Physical Address. . . . . . . . . : 00-08-A1-00-9F-32 Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 192.168.1.100 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.1 DNS Servers . . . . . . . . . . . : 204.127.202.19 216.148.227.79 Lease Obtained. . . . . . . . . . : Saturday, December 28, 2002 8:53:40 AM Lease Expires . . . . . . . . . . : Sunday, December 29, 2002 8:53:40 AM PPP adapter {6A724E76-AB59-4ABC-BBF5-41CA4410EB8D}: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface Physical Address. . . . . . . . . : 00-53-45-00-00-00 Dhcp Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 172.165.155.106 Subnet Mask . . . . . . . . . . . : 255.255.255.255 Default Gateway . . . . . . . . . : DNS Servers . . . . . . . . . . . : 64.12.104.134 NetBIOS over Tcpip. . . . . . . . : Disabled You can also use ipconfig to release and renew IP addresses, and perform other troubleshooting functions as well. For example, to renew an adapter's IP address, use this command: ipconfig /renew " adapter name " where adapter name is the name of the adapter whose IP address you want to renew. Make sure to put quotes around the adapter name and use spaces if there is more than one word in the adapter name. Table 5-9 lists other switches you can use with ipconfig . Table 5-9. Command-line switches for ipconfig
|