| 1 | % System Administration and IP Services |
|---|
| 2 | |
|---|
| 3 | # TCP/IP Networking Exercises |
|---|
| 4 | |
|---|
| 5 | * Commands preceded with "$" imply that you should execute the command as |
|---|
| 6 | a general user - not as root. |
|---|
| 7 | * Commands preceded with "#" imply that you should be working as root. |
|---|
| 8 | * Commands with more specific command lines (e.g. "rtrX>" or "mysql>") |
|---|
| 9 | imply that you are executing commands on remote equipment, or within |
|---|
| 10 | another program. |
|---|
| 11 | |
|---|
| 12 | # Practice: ping, netstat, tcpdump, traceroute, arp, route |
|---|
| 13 | |
|---|
| 14 | ## Check your network configuration |
|---|
| 15 | |
|---|
| 16 | Check it with: |
|---|
| 17 | |
|---|
| 18 | ~~~ |
|---|
| 19 | $ sudo ifconfig eth0 |
|---|
| 20 | ~~~ |
|---|
| 21 | |
|---|
| 22 | Do you see an IP address on your network card? It should look like this: |
|---|
| 23 | |
|---|
| 24 | ~~~ |
|---|
| 25 | eth0 Link encap:Ethernet HWaddr 52:54:8e:12:66:49 |
|---|
| 26 | inet addr:10.10.0.xx Bcast:10.10.0.255 Mask:255.255.255.0 |
|---|
| 27 | ~~~ |
|---|
| 28 | |
|---|
| 29 | This is your machine's IP address. |
|---|
| 30 | |
|---|
| 31 | If you wanted to manually configure the IP address of eth0 (your computer's |
|---|
| 32 | network card) to give it an IP address (10.10.0.xx), then you would write: |
|---|
| 33 | |
|---|
| 34 | ~~~ |
|---|
| 35 | $ sudo ifconfig eth0 10.10.0.xx/24 |
|---|
| 36 | $ sudo route add default gw 10.10.0.254 |
|---|
| 37 | ~~~ |
|---|
| 38 | |
|---|
| 39 | Note: Don't do this now! As we are logged in using SSH, don't do this or |
|---|
| 40 | you may end up breaking your network connection to your machine. |
|---|
| 41 | |
|---|
| 42 | ## netstat |
|---|
| 43 | |
|---|
| 44 | Look at your routing table: |
|---|
| 45 | |
|---|
| 46 | ~~~ |
|---|
| 47 | $ netstat -rn |
|---|
| 48 | ~~~ |
|---|
| 49 | |
|---|
| 50 | * What do you notice? |
|---|
| 51 | * Is the default gateway configured? |
|---|
| 52 | * How do you know? |
|---|
| 53 | |
|---|
| 54 | Review the presentation if you are not sure. |
|---|
| 55 | |
|---|
| 56 | * What is your default gateway? |
|---|
| 57 | * On what network interface is your default gateway reachable ? |
|---|
| 58 | |
|---|
| 59 | Here's another way to look at your routing table: |
|---|
| 60 | |
|---|
| 61 | ~~~ |
|---|
| 62 | $ ip route |
|---|
| 63 | ~~~ |
|---|
| 64 | |
|---|
| 65 | ## ping |
|---|
| 66 | |
|---|
| 67 | Let's ping the default gateway: |
|---|
| 68 | |
|---|
| 69 | ~~~ |
|---|
| 70 | $ ping 10.10.0.254 |
|---|
| 71 | ~~~ |
|---|
| 72 | |
|---|
| 73 | (Stop it with CTRL+C) |
|---|
| 74 | |
|---|
| 75 | Let's ping something outside, on the Internet. For example, nsrc.org |
|---|
| 76 | |
|---|
| 77 | ~~~ |
|---|
| 78 | $ ping nsrc.org |
|---|
| 79 | ~~~ |
|---|
| 80 | |
|---|
| 81 | Do you get an answer ? |
|---|
| 82 | |
|---|
| 83 | If not, check: |
|---|
| 84 | |
|---|
| 85 | * That you have a gateway configured |
|---|
| 86 | * That in the file /etc/resolv.conf there is an entry for "nameserver" |
|---|
| 87 | * Do you notice anything about the response time? How far away is nsrc.org? |
|---|
| 88 | |
|---|
| 89 | Verify 10.10.0.254 is configured as your default gateway: |
|---|
| 90 | |
|---|
| 91 | $ netstat -rn |
|---|
| 92 | |
|---|
| 93 | Now, remove your default gateway: |
|---|
| 94 | |
|---|
| 95 | ~~~ |
|---|
| 96 | $ sudo route delete default |
|---|
| 97 | ~~~ |
|---|
| 98 | |
|---|
| 99 | Check that it's gone |
|---|
| 100 | |
|---|
| 101 | ~~~ |
|---|
| 102 | $ netstat -rn |
|---|
| 103 | ~~~ |
|---|
| 104 | |
|---|
| 105 | How can you be sure that the default gateway is no longer configured? |
|---|
| 106 | Now, try to ping the local NOC machine. |
|---|
| 107 | |
|---|
| 108 | ~~~ |
|---|
| 109 | $ ping 10.10.0.250 |
|---|
| 110 | ~~~ |
|---|
| 111 | |
|---|
| 112 | Now let's ping a machine outside our network (nsrc.org): |
|---|
| 113 | |
|---|
| 114 | ~~~ |
|---|
| 115 | $ ping nsrc.org |
|---|
| 116 | ~~~ |
|---|
| 117 | |
|---|
| 118 | The ip address of nsrc.org is `128.223.157.19` |
|---|
| 119 | |
|---|
| 120 | ~~~ |
|---|
| 121 | $ ping 128.223.157.19 |
|---|
| 122 | ~~~ |
|---|
| 123 | |
|---|
| 124 | What do you observe? |
|---|
| 125 | What is the consequence of removing the default gateway? |
|---|
| 126 | |
|---|
| 127 | Re-establish the default gateway: |
|---|
| 128 | |
|---|
| 129 | ~~~ |
|---|
| 130 | $ sudo route add default gw 10.10.0.254 |
|---|
| 131 | ~~~ |
|---|
| 132 | |
|---|
| 133 | Check that the default gateway is enabled again by pinging nsrc.org: |
|---|
| 134 | |
|---|
| 135 | ~~~ |
|---|
| 136 | $ ping nsrc.org |
|---|
| 137 | ~~~ |
|---|
| 138 | |
|---|
| 139 | ## traceroute |
|---|
| 140 | |
|---|
| 141 | Traceroute to nsrc.org |
|---|
| 142 | |
|---|
| 143 | ~~~ |
|---|
| 144 | $ traceroute nsrc.org |
|---|
| 145 | ~~~ |
|---|
| 146 | |
|---|
| 147 | Try again, this time with the -n option: |
|---|
| 148 | |
|---|
| 149 | ~~~ |
|---|
| 150 | $ traceroute -n nsrc.org |
|---|
| 151 | ~~~ |
|---|
| 152 | |
|---|
| 153 | Observe the difference with and without the '-n' option. Do you know what it is? |
|---|
| 154 | |
|---|
| 155 | Try this again with the command "mtr": |
|---|
| 156 | |
|---|
| 157 | ~~~ |
|---|
| 158 | $ mtr nsrc.org |
|---|
| 159 | ~~~ |
|---|
| 160 | |
|---|
| 161 | You can stop mtr with CTRL-C. |
|---|
| 162 | |
|---|
| 163 | ## tcpdump |
|---|
| 164 | |
|---|
| 165 | Run tcpdump on your system: |
|---|
| 166 | |
|---|
| 167 | ~~~ |
|---|
| 168 | $ sudo tcpdump -n -i eth0 icmp |
|---|
| 169 | ~~~ |
|---|
| 170 | |
|---|
| 171 | (Note the use of the icmp keyword to limit viewing ICMP traffic) |
|---|
| 172 | |
|---|
| 173 | Ask the instructor(s) or your neighbor to ping your machine, and look at |
|---|
| 174 | your screen. |
|---|
| 175 | |
|---|
| 176 | Now delete the default route on your system: |
|---|
| 177 | |
|---|
| 178 | ~~~ |
|---|
| 179 | $ sudo route delete default |
|---|
| 180 | ~~~ |
|---|
| 181 | |
|---|
| 182 | Repeat the ping (ask the instructor or neighbor) |
|---|
| 183 | |
|---|
| 184 | Does it make a difference ? |
|---|
| 185 | |
|---|
| 186 | ## arp table |
|---|
| 187 | |
|---|
| 188 | Run the command: |
|---|
| 189 | |
|---|
| 190 | ~~~ |
|---|
| 191 | $ arp -a |
|---|
| 192 | ~~~ |
|---|
| 193 | |
|---|
| 194 | And |
|---|
| 195 | |
|---|
| 196 | ~~~ |
|---|
| 197 | $ arp -an |
|---|
| 198 | ~~~ |
|---|
| 199 | |
|---|
| 200 | Now, try and ping another host on the network (10.10.0.1 - .98) |
|---|
| 201 | |
|---|
| 202 | Run `arp -an` again. |
|---|
| 203 | |
|---|
| 204 | What do you notice ? |
|---|
| 205 | |
|---|
| 206 | Now try: |
|---|
| 207 | |
|---|
| 208 | ~~~ |
|---|
| 209 | $ ping -c 2 nsrc.org |
|---|
| 210 | $ arp -an |
|---|
| 211 | ~~~ |
|---|
| 212 | |
|---|
| 213 | * What do you notice ? |
|---|
| 214 | * When is ARP used, |
|---|
| 215 | * When is it not used ? |
|---|
| 216 | |
|---|
| 217 | ## Reaching another network |
|---|
| 218 | |
|---|
| 219 | * Try to ping: 10.10.1.1 |
|---|
| 220 | |
|---|
| 221 | * Try to traceroute (or mtr) to 10.10.1.1 |
|---|
| 222 | |
|---|
| 223 | Now, remove the default route: |
|---|
| 224 | |
|---|
| 225 | ~~~ |
|---|
| 226 | $ sudo route delete default |
|---|
| 227 | ~~~ |
|---|
| 228 | |
|---|
| 229 | Now, try to ping 10.10.1.1 again. |
|---|
| 230 | |
|---|
| 231 | * What happened ? |
|---|
| 232 | |
|---|
| 233 | For your knowledge, 10.10.1.1 is a PC on network 10.10.1.0/24. |
|---|
| 234 | |
|---|
| 235 | This network is reachable via the router 10.10.0.221. |
|---|
| 236 | |
|---|
| 237 | * What route do you need to add to reach 10.10.1.1 (not a default route ?) |
|---|
| 238 | |
|---|
| 239 | * What route do you need to add to reach 10.10.1.2 (another PC on the |
|---|
| 240 | same network) ? |
|---|
| 241 | |
|---|
| 242 | You can solve both questions with one answer! |
|---|
| 243 | |
|---|
| 244 | ## IPv6 |
|---|
| 245 | |
|---|
| 246 | Do this: |
|---|
| 247 | |
|---|
| 248 | $ sudo /sbin/ifconfig eth0 inet6 add fdba:dc55:48c7::00:XX/64 |
|---|
| 249 | |
|---|
| 250 | ... replace XX with the number of your VM ! (01, 02, ... , 23, ...) |
|---|
| 251 | |
|---|
| 252 | Now, try to ping6 each other: |
|---|
| 253 | |
|---|
| 254 | $ ping6 fdba:dc55:48c7::00:YY |
|---|
| 255 | |
|---|
| 256 | Where YY is the IP of another VM in the class. |
|---|