Working with Ipconfig and Ping
8. Remove an IPv6 with the following syntax
netsh interface ipv6 delete address interface=Local Area Connection address=2001:ab1:442e:1323::7
9. Type ipconfig to verify that the address was removed.
If you wish, you can create batch files using various netsh syntax in an effort to save time in the future.
Now, let’s discuss the route command. Route enables you to display and make changes to the local IP routing table of the computer, which displays IP connections to other networks as well as testing networks. Generally, a client computer does not have routes to other actual networks, mainly because a client computer is not normally intended for that role. Also, most client computers have only one network adapter.
In order to create routes to other networks, a second network adapter is required.
When a computer has two network adapters, it is known as a multi-homed machine.
c05ImplementingTCP/IPintheComman115 Page 115 12/23/10 9:51:21 PM f-392
c05ImplementingTCP/IPintheComman115 Page 115 12/23/10 9:51:21 PM f-392 /Users/f-392/Desktop/Nalini 23.9/ch05/Users/f-392/Desktop/Nalini 23.9/ch05
116 | Lesson 5
If it has two and only two network adapters, it is specifically known as a dual-homed machine.
10. Type the command route print. This should display results similar to Figure 5-21. This command gives the same result as netstat –r, but it is more commonly used.
Figure 5-21 Route print
This command shows a list of network adapters (or interfaces) on the local computer, including the MAC address and name of each. Then the IPv4 Route Table is displayed.
You will notice several networking connections. The Network Destination column tells you where the computer is trying to connect. The Netmask is the subnet mask for that particular Network Destination. The Gateway is the IP address of the host that is used to gain access to the remote network. The Interface is the IP address of the net- work adapter that is making the connection to the other network. The Metric column specifies an integer between 1 and 9999; this metric is associated with the speed of the connection, the amount of hops across networks, and so on. Normally, the lowest metric is selected for connections to other networks. This is not an issue if the com- puter (often a router) only has two or three connections.
You will notice a 0.0.0.0 network destination. This is the local network when no IP address is associated with the computer (for example, when we executed the com- mand ipconfig/release). Then you will see the local network that the computer is a part of; in the figure, it is 10.254.254.0, with a subnet mask of 255.255.255.0. This is the network number for this computer, which has an IP address of 10.254.254.112.
Single IP addresses also get a route line item, as you can see in the third line.
The local loopback network (127.0.0.0) and the actual local loopback IP address (127.0.0.1) also get route line items, and so on.
c05ImplementingTCP/IPintheComman116 Page 116 12/23/10 9:51:21 PM f-392
c05ImplementingTCP/IPintheComman116 Page 116 12/23/10 9:51:21 PM f-392 /Users/f-392/Desktop/Nalini 23.9/ch05/Users/f-392/Desktop/Nalini 23.9/ch05
Implementing TCP/IP in the Command Line | 117
There is also an IPv6 Route Table if you are running that protocol. This table shows link-local and global unicast address line items.
11. Add and remove routes. Adding a router requires syntax similar to the netsh command we used to add IP addresses. In the following portion of this exercise, we will add a fictitious route using our local IP address as the interface that makes the connection to the remote network:
a. Type the command route add 192.168.1.0 mask 255.255.255.0 [LocalIPAddress]. An example of this is shown in Figure 5-22.
Figure 5-22 Route add
The network we are attempting to connect to is 192.168.1.0, and it has a default Class C subnet mask of 255.255.255.0. The word “mask” takes the place of “sub- net mask.” Then we used our local IP address, in this case 10.254.254.112, to connect to the remote network. After we pressed Enter, a simple OK! Message appeared. This means that the route has been added to the local routing table.
b. Type the command route print. You will see the new route in the IPv4 Route Table, as shown in Figure 5-23.
The new route is created for the network address 192.168.1.0, as well as for the broadcast address 192.168.1.255.
c. Type the command route delete 192.168.1.0 mask 255.255.255.0. This should remove the route you added previously. You could also remove all added routes with one command: route -f. But be careful with this command. Depending on the operating system and protocols used, as well as the network configuration, this could stop all network connections.
Figure 5-23
Route print with a new route
New route c05ImplementingTCP/IPintheComman117 Page 117 12/23/10 9:51:22 PM f-392
c05ImplementingTCP/IPintheComman117 Page 117 12/23/10 9:51:22 PM f-392 /Users/f-392/Desktop/Nalini 23.9/ch05/Users/f-392/Desktop/Nalini 23.9/ch05
118 | Lesson 5
d. Type the command route print to view the results. If you start to have any issues with your routing table, consider stopping and restarting TCP/IP, or even restarting the computer. By the way, TCP/IP can be reset in the command line by typing the following command:
netsh int ip reset c:\resetlog.txt.
Generally, these added routes will be lost if TCP/IP or the computer is restarted. However, routes can also be added in a persistent manner by using the –p option. The p stands for persistent; it preserves the route within the registry even if TCP/IP is restarted.
Again, the idea behind routing is to make connections to remote networks. See Figure 5-24 for some network documentation.
Figure 5-24
Routing documentation
Cloud Router
A Router
B Switch
A Switch
B
LAN A LAN B
E0 10.254.254.1 E0 10.253.253.1
S0 63.21.15.121 S0 63.21.15.128
In the figure, there are two LANs, LAN A and LAN B. By default, computers on these LANs would not be able to talk to each other because they are separated by routers and the “cloud”
(whatever “the cloud” happens to be). To allow the computers on each LAN to talk to each other, a specific route would have to be created on each LAN’s router. Each router has a LAN address (known as E0) and a WAN address (known as S0). These are also known as private and public addresses, respectively. Let’s say that the subnet mask used on both LANs is 255.255.255.0, just like the CIDR setup we have been using. On router A, we would need the following syntax:
Route add 10.253.253.0 mask 255.255.255.0 63.21.15.121
This makes the connection to the 10.253.253.0 network utilizing the LAN B router’s public address. This address is labeled as S0, or the first serial connection, which is used to connect to different networks.
On router B, we would need the following syntax:
Route add 10.254.254.0 mask 255.255.255.0 63.21.15.128
This makes the connection to the 10.254.254.0 network utilizing the LAN A router’s public address.
Once these two connections have been made, communications should be possible between the two LANs.
If the routers are Windows Servers, some additional configuration would be necessary prior to adding these route line items. The servers would need to be equipped with two network adapters, making them multi-homed computers. Then, Routing and Remote Access would have to be configured to allow for IP forwarding. (Alternate software such as ISA could also be used.) After that, the route line items could be added.
If you were using conventional black box routers or appliances, TCP/IP protocols such as RIP and OSPF would be employed to streamline and automate the process:
• Routing information protocol (RIP) is a distance vector protocol that uses algorithms to decipher which route to send data packets.
c05ImplementingTCP/IPintheComman118 Page 118 12/29/10 7:57:05 AM user-s146
c05ImplementingTCP/IPintheComman118 Page 118 12/29/10 7:57:05 AM user-s146 /Users/user-s146/Desktop/Merry_X-Mas/New/Users/user-s146/Desktop/Merry_X-Mas/New
Implementing TCP/IP in the Command Line | 119
• Open shortest path first (OSPF) is a link-state protocol that monitors the network for routers that have a change in their link-state, meaning whether they were turned off or on or restarted.
We’ll talk more about routing protocols in Lesson 7.
UTILIZE THE NET COMMAND
GET READY. Although not really considered part of the TCP/IP command set, the net com- mand can display all kinds of important networking data, and it allows you to configure various networking options such as services.
1. Type the net command. View the results. You will see options such as view, user, ses- sion, start, and stop. Each of these options can help you analyze networking configu- rations and make modifications.
2. Type the command net view. This should show the computers on your immediate net- work, whether they operate as a workgroup or a domain. Each computer listed is pre- ceded by a double backslash. This indicates a UNC or Universal Naming Convention. The UNC can be used when mapping drives and connecting to computers for other reasons.
3. Type the command net time \\[localcomputer]. For example, type net time \\
desktop-lamp1, as shown in Figure 5-25. This displays the current time of the computer.
This command can also be used to synchronize time to other computers or time servers.
Figure 5-25 Net time