traceroute just for note

There are three main primary objectives of traceroute tool. These objectives fulfilled by tracroute gives an insight to your network problem.

  1. The entire path that a packet travels through
  2. Names and identity of routers and devices in your path
  3. Network Latency or more specifically the time taken to send and receive data to each devices on the path

Its a tool that can be used to very the path that your data will take to reach its destination, without actually sending your data.

Traceroute is a very handy tool written by >Van Jacobson that can show you the route that packets take from one host to another. It can also be used sometimes to help debug network problems, if you know how to interpret its results.

How Does it Work?

Every IP packet can specify how many hops it can go through before it is no longer forwarded on. When a packet is no longer forwarded on, that router just forgets all about it, but it also will usually send out a message to the source host saying, "Hey, sorry, but your packet died here." So, traceroute cleverly manipulates these values so that the first round of packets it sends out to the designated host are specified such that they can only go through one hop before dying. So that first hop gets those packets, sees that it's not supposed to forward them on any further and doesn't, and then sends a message back to the source host telling it that the packets died. When traceroute receives the "your packets died here" message from the router, it knows that's the first hop. It then sends on the second round of packets specifying that they can only go through two hops, and the cycle continues. It finishes when it gets a response from the final destination. For each hop, traceroute then displays the RTT, Round Trip Time, or the time difference between when the probe was sent from traceroute and the time the response arrived for each packet.

Let's take a look at an example traceroute:
[onyx]:[3:30am]:[/home/rnejdl] > traceroute www.neo.com
traceroute to www.neo.com (209.151.241.200), 30 hops max, 40 byte packets
 1  border1 (209.39.6.1)  2.053 ms  2.054 ms  2.322 ms
 2  host-c-129.vcso.verio.net (207.55.203.129)  3.644 ms  1.195 ms  1.180 ms
 3  int1-s1-0.dlls.tx.verio.net (199.1.162.153)  1.810 ms  1.795 ms  1.828 ms
 4  ge-5-0-0.a10.dllstx01.us.ra.verio.net (199.1.141.10)  2.125 ms  2.070 ms  2.020 ms
 5  ge-6-0.r00.dllstx01.us.bb.verio.net (129.250.31.49)  1.975 ms  1.969 ms  2.013 ms
 6  ATM3-0.BR1.DFW9.ALTER.NET (137.39.23.221)  3.269 ms  3.175 ms  2.989 ms
 7  140.at-5-0-0.XR2.DFW9.ALTER.NET (152.63.98.134)  3.583 ms  3.342 ms  3.167 ms
 8  184.at-2-0-0.TR2.DFW9.ALTER.NET (152.63.98.50)  3.483 ms  3.249 ms  3.448 ms
 9  128.at-5-1-0.TR2.LAX9.ALTER.NET (152.63.0.230)  35.689 ms  35.958 ms  35.937 ms
10  196.ATM6-0.XR2.LAX4.ALTER.NET (152.63.112.185)  38.666 ms  38.775 ms  38.837 ms
11  192.ATM4-0.GW6.LAX4.ALTER.NET (152.63.113.149)  38.846 ms  38.879 ms  39.045 ms
12  softawareoc3-gw.customer.alter.net (157.130.200.214)  34.409 ms  34.260 ms 34.437 ms
13  newDuke-p1.softaware.com (209.85.0.2)  34.901 ms  35.183 ms  35.111 ms
14  stonewall.softaware.com (206.83.165.222)  35.395 ms  35.748 ms  35.395 ms
15  flint-softaware.mla.cyberverse.net (209.85.63.254)  42.941 ms  37.415 ms  50.875 ms
16  tucker.mla.cyberverse.net (209.151.224.66)  56.009 ms  62.434 ms  47.725 ms
17  neon.neo.com (209.151.241.200)  98.993 ms  76.639 ms  72.790 ms
[onyx]:[3:30am]:[/home/rnejdl] >
From this traceroute, you can see that it took 17 hops to go from onyx.training.verio.net to www.neo.com and that the round trip time was roughly 72-98 ms (based on the 3 numbers on the last line). Keep in mind that the RTT's reported are the round trip times from the source host to that router hop. It's not a cumulative sum of the previous times. Each hop is going to add some time to the path, so you'd expect each hop to take a little bit more time to get to than the last. Looking at this example, you can see that this is pretty much the case here, except for slight fluctuations on the orders of milliseconds due to network traffic.

Now an important thing to know when using traceroute is what the asterisks/stars mean. If you see traceroute print out a star instead of a round trip time, that means that either your probe packet got dropped, or the reply back to you for that probe got lost along the way. This is usually referred to as "packet loss," and we will discuss this later.

Understanding the Route

To understand how to interpret a route, you will need to know a little bit about interpretting reverse DNS. When ever a traceroute is done, the program will look up the reverse DNS of each host as it goes and print that information as part of each line. This can help to give you clues as to each network that a packet goes through when it travels from you to the final destination. Let's go through an example and show how to interpret it.
[onyx]:[4:07am]:[/home/rnejdl] > traceroute www.idsoftware.com
traceroute to charon.idsoftware.com (192.246.40.185), 30 hops max, 40 byte packets
 1  border1 (209.39.6.1)  2.103 ms  1.995 ms  2.407 ms
 2  host-c-129.vcso.verio.net (207.55.203.129)  1.324 ms  1.158 ms  1.169 ms
 3  int1-s1-0.dlls.tx.verio.net (199.1.162.153)  1.827 ms  1.866 ms  1.858 ms
 4  ge-5-0-0.a10.dllstx01.us.ra.verio.net (199.1.141.10)  2.136 ms  2.084 ms  2.097 ms
 5  ge-6-0.r00.dllstx01.us.bb.verio.net (129.250.31.49)  2.056 ms  1.954 ms  1.981 ms
 6  ATM3-0.BR1.DFW9.ALTER.NET (137.39.23.221)  3.122 ms  3.078 ms  3.344 ms
 7  140.at-6-0-0.XR2.DFW9.ALTER.NET (152.63.98.130)  3.260 ms  3.507 ms  3.330 ms
 8  284.ATM7-0.XR2.DFW4.ALTER.NET (152.63.96.165)  4.436 ms  4.342 ms  4.306 ms
 9  194.ATM9-0-0.GW1.DFW1.ALTER.NET (146.188.240.45)  5.085 ms  4.628 ms  5.285 ms
10  savvis-dfw-gw.customer.ALTER.NET (157.130.128.54)  5.571 ms  5.964 ms  5.462 ms
11  idsoft-1.CR-1.usdlls.savvis.net (209.176.32.178)  11.800 ms  9.365 ms  10.870 ms
12  charon.idsoftware.com (192.246.40.185)  10.687 ms  9.927 ms  11.687 ms
[onyx]:[4:07am]:[/home/rnejdl] >
In this example, we have tracerouted to www.idsoftware.com from a host within Verio's network. We can now analyze each hop along the way.
  1. border1 is the router for the this network.
  2. host-c-129.vcso.verio.net is the router that provides connectivity for the entire 8700 location.
  3. int1-s1-0.dlls.tx.verio.net is Serial 1/0 on the router dlls.tx.verio.net, the other side of the T3 between the 8700 location and the Infomart.
  4. ge-5-0-0.a10.dllstx01.us.ra.verio.net is the Gigabit Ethernet Interface 5/0/0 on a10.dllstx.01.us.ra.verio.net.
  5. ge-6-0.r00.dllstx01.us.ra.verio.net is another Gigabit Ethernet Interface on a different router within the same location, the Infomart. This router handles our peering for Verio in Dallas.
  6. ATM3-0.BRI.DFW9.ALTER.NET is Alter.net's router that peers directly with Verio in Dallas.
  7. 140.at-6-0-0.XR2.DFW9.ALTER.NET is an ATM connection on another router with the Dallas/Fort Worth area.
  8. 284.ATM7-0.XR2.DFW4.ALTER.NET is another ATM connection in the Dallas/Fort Worth area.
  9. 194.ATM9-0-0.GW1.DFW1.ALTER.NET is yet another ATM connection on a different router within Alter.net's network in Dallas/Fort Worth.
  10. savvis-dfw-gw.customer.ALTER.NET is the serial IP savvis.net's router that connects to Alter.net's network.
  11. idsoft-1.CR-1.usdlls.savvis.net is Id Software's serial IP for their router that connects to savvis.net's network. It appears that ID Software is a customer of savvis.net.
  12. charon.idsoftware.com is the actual name of the machine where www.idsoftware.com's website is hosted.
From this traceroute, we can tell that www.idsoftware.com is hosted by ID software themselves in the Dallas/Fort Worth metroplex. We also know that ID Software is a customer of savvis.net, who is in turn a customer of Alter.net.

Let's look at another traceroute:

[onyx]:[4:07am]:[/home/rnejdl] > traceroute www.7up.com
traceroute to 7up.com (192.41.37.40), 30 hops max, 40 byte packets
 1  border1 (209.39.6.1)  2.093 ms  2.019 ms  2.336 ms
 2  host-c-129.vcso.verio.net (207.55.203.129)  3.700 ms  1.171 ms  1.193 ms
 3  int1-s1-0.dlls.tx.verio.net (199.1.162.153)  1.810 ms  1.883 ms  1.856 ms
 4  ge-5-0-0.a10.dllstx01.us.ra.verio.net (199.1.141.10)  2.144 ms  2.113 ms  2.027 ms
 5  ge-6-0-0.r01.dllstx01.us.bb.verio.net (129.250.28.190)  2.096 ms  2.070 ms 2.176 ms
 6  p1-0-0-0.r01.oremut01.us.bb.verio.net (129.250.2.41)  59.328 ms  59.354 ms 59.319 ms
 7  pvu1.vwhpvu1.verio.net (129.250.29.202)  59.516 ms  60.039 ms  59.890 ms
 8  7up.com (192.41.37.40)  60.132 ms  60.405 ms  60.496 ms
[onyx]:[4:11am]:[/home/rnejdl] >
This traceroute follows much the same path as the last one up to hop 5. Hop 6 is the Verio router in Orem, Utah that Iserver uses. The router on hop 7, pvu1.vwhpvu1.verio.net is the border router (the router that connects Iserver to the Verio backbone) for Iserver. Finally, we can see that www.7up.com is hosted on an Iserver platform.

We will look at one more traceroute that shows another example of what you might see.

[onyx]:[4:22am]:[/home/rnejdl] > traceroute www.hellers.com
traceroute to www.hellers.com (207.197.221.102), 30 hops max, 40 byte packets
 1  border1 (209.39.6.1)  3.743 ms  2.090 ms  2.430 ms
 2  host-c-129.vcso.verio.net (207.55.203.129)  1.351 ms  1.187 ms  1.126 ms
 3  int1-s1-0.dlls.tx.verio.net (199.1.162.153)  1.810 ms  1.801 ms  1.810 ms
 4  ge-5-0-0.a10.dllstx01.us.ra.verio.net (199.1.141.10)  2.132 ms  2.070 ms  2.022 ms
 5  ge-6-0.r00.dllstx01.us.bb.verio.net (129.250.31.49)  2.143 ms  2.231 ms  2.022 ms
 6  p1-1-0-2.r03.mclnva01.us.bb.verio.net (129.250.2.210)  45.922 ms  45.934 ms 45.967 ms
 7  p4-0-1.r00.mclnva02.us.bb.verio.net (129.250.2.62)  45.999 ms  45.979 ms  45.805 ms
 8  fa-3-0-0.a06.vinnva01.us.ra.verio.net (129.250.30.165)  46.159 ms  46.191 ms 46.215 ms
 9  fa-0.n01.vinnva01.us.ra.verio.net (207.22.81.103)  47.217 ms  46.802 ms  46.860 ms
10  router.hellers.com (207.197.221.1)  73.894 ms  73.852 ms  74.150 ms
11  dybbuk.hellers.com (207.197.221.3)  85.513 ms *  75.824 ms
[onyx]:[4:22am]:[/home/rnejdl] >

This last traceroute is to www.hellers.com. This website is hosted on the Verio network, however, it is hosted by a customer of Verio's, so is not Verio's responsibility, other than maintaining connectivity.

Caveats and Quirks

Before we continue on, there are a couple little caveats to using traceroute that you should be aware of, so you don't accidently misinterpret the results.

The first caveat to be aware of is that sometimes it will look like the last hop on a traceroute dropped a packet, when it really didn't. This is due to both the fact that this host is the actual final destination of your traceroute probes, and how certain Operating Systems handle ICMP. (ICMP, Internet Control Message Protocol, is one protocol that machines on the Internet use to send messages to each other, and the "Your packet died here" message that traceroute relies on is an ICMP message.) Since the last hop is your destination, instead of that host sending you back an ICMP message saying "Sorry your packet died here," that host will send back a different ICMP message saying "Hi, your packet made it here, but this port is unreachable." This is because traceroute purposefully sets the probe packet's destination to be some large port number that will most likely be unreachable at the destination host because it wants to receive that "port unreachable" message back. The caveat here has to do with the fact that some OS's, such as IOS (which Cisco routers run) and Sun Solaris, purposefully drop ICMP responses like "port unreachable" if it gets too many of them in a short period of time. They do this presumably as a security precaution. So, if you were to add in more delay between probes, you wouldn't see this erroneous packet loss.

Another caveat of traceroute is that ICMP, which is the protocol traceroute relies on to get responses from each hop, is usually the lowest priority protocol. So if one router is really busy it might decide to drop ICMP messages, and you will see lots of packet loss, but that router might be forwarding on more common, higher priority traffic just fine.

Also, some sites will filter ICMP for various reasons, so it might appear in a traceroute that a site might be unreachable, but in fact it is reachable.


Tracking Down Network Problems

So now that you have a basic understanding of traceroute, it's time to learn how to use traceroute to track down network problems. The first kind of network problem that traceroute can help you debug would be a loss or lack of connectivity to a site. If you appear to be having problems reaching a remote site, like a web site, do a traceroute to that site. If the traceroute reaches that site fine, then chances are that you have connectivity to the host, but that the web server on that host crashed. But, if the packets start to die somewhere along the path, it's likely that some router along the way, or the host itself is down. Here is an example traceroute:
traceroute to 209.0.0.210 (209.0.0.210): 1-30 hops, 38 byte packets
1  SF-rt5-fe9-0.geo.net (166.90.6.1)  0.48 ms  0.440 ms  0.378 ms
2  SF-core1-h1.geo.net (166.90.1.17)  0.618 ms  0.571 ms  0.521 ms
3  SF-rt2-f0.geo.net (166.90.5.7)  1.19 ms  1.94 ms  1.13 ms
4  *  *  *
5  *  *  *
Just remember that such a traceroute can also be an example of a firewall that is filtering packets, or a router that throws away the kinds of packets that traceroute depends on when it gets overloaded.

Debugging Network Slowdowns

Using traceroute's results to see what hops IP packets take from you to a remote host is really straight forward. However, using traceroute's results to debug where "slowness" occurs in a link is fairly tricky for a number of different reasons. The first of which is the fact that traceroute only shows you the hops from you to a remote host, not the hops from the remote host to you. So, the best way to determine where network slowness is occurring is to do a traceroute from host A to host B, and then another traceroute from host B back to host A. By looking at both, a trained eye can usually get a pretty good idea where the network slowness is occurring. This is due to the fact that pretty much every Tier1 ISP on the Internet uses closest-exit routing which often results in asymmetric routes (completely different routes from host A to B than from host B to A).

For instance, host A might be on the west coast using ISP X, and host B might be on the east coast using ISP Y. The path from host A to host B will then probably exit ISP X as soon as it can, most likely at some peering point on the west coast and enter ISP Y's network from there onto host B. Conversely, the path from host B to host A will most likely exit ISP Y's network as soon as it can on the east coast, and enter ISP X's network and continue on to host A.

Here's an example:
traceroute to web-proxy.geo.net (166.90.90.163)
 1  E40-RTR-E40-SERVER72-ETHER.MIT.EDU (18.72.0.1)  4 ms  4 ms  4 ms
 2  EXTERNAL-RTR-FDDI.MIT.EDU (18.168.0.12)  4 ms  4 ms  4 ms
 3  cambridge2-br2.bbnplanet.net (192.233.33.6)  4 ms  4 ms  4 ms
 4  cambridge1-br1.bbnplanet.net (4.0.2.25)  4 ms  78 ms  105 ms
 5  nyc1-br2.bbnplanet.net (4.0.2.85)  12 ms  12 ms  12 ms
 6  nynap.bbnplanet.net (4.0.1.26)  12 ms  12 ms  16 ms
 7  sprint-nap.geo.net (192.157.69.43)  94 ms  82 ms  74 ms
 8  SF-rt5-a1.geo.net (166.90.4.33)  70 ms  78 ms  74 ms
 9  SF-core1-h1.geo.net (166.90.1.17)  82 ms  78 ms  74 ms
10  SF-rt2-f0.geo.net (166.90.5.7)  273 ms  234 ms  98 ms
11  web-proxy.geo.net (166.90.90.163)  133 ms  90 ms  82 ms

traceroute to BIG-SCREW.MIT.EDU (18.72.0.176), 30 hops max, 40 byte packets
 1  SF-rt2-f2.geo.net (166.90.2.13)  1.218 ms  1.219 ms  1.479 ms
 2  SF-core1-f0.geo.net (166.90.5.4)  0.704 ms  0.68 ms  0.678 ms
 3  MAE-West-h0.geo.net (166.90.1.34)  3.926 ms  3.402 ms  4.285 ms
 4  sanjose1-br1.bbnplanet.net (198.32.184.19)  5.071 ms  4.839 ms  6.973 ms
 5  su-bfr.bbnplanet.net (4.0.1.10)  6.695 ms  6 ms  8.342 ms
 6  chicago1-br2.bbnplanet.net (4.0.3.165)  71.597 ms  70.278 ms  70.166 ms
 7  boston1-br1.bbnplanet.net (4.0.2.245)  76.612 ms 74.881 ms 75.66 ms
 8  boston1-br2.bbnplanet.net (4.0.2.250)  74.099 ms  77.012 ms  76.715 ms
 9  cambridge2-br1.bbnplanet.net (4.0.1.186)  75.399 ms  75.376 ms  74.932 ms
10  ihtfp.mit.edu (192.233.33.3)  78.895 ms  76.066 ms  76.434 ms
11  E40-RTR-FDDI.MIT.EDU (18.168.0.11)  77.556 ms  76.115 ms  75.627 ms
12  BIG-SCREW.MIT.EDU (18.72.0.176)  76.484 ms  76.226 ms  77.748 ms
Note the vastly different paths that these two traceroutes take from host A to host B and from host B to host A, each with a different number of hops. The first traceroute shows the path from MIT to geo.net goes through Sprint Nap, an exchange point in New Jersey. This makes sense, since MIT is on the east coast and BBN is using closest exit routing. The second traceroute shows that the path from geo.net in San Francisco back to MIT goes through MAE West, an exchange point in the San Francisco Bay Area, the closest exit point for geo.net.

Now, to make the issue more confusing, the second reason why tracking down network "slowness" is tricky is the fact that in networking there is no "slow" or "fast", but instead there are bandwidth and latency, which are two different concepts that can both determine how "fast" a network is. (If you are unclear on the difference between bandwidth and latency, check out a cool paper written by Stuart Cheshire called "It's the Latency, Stupid".

Tracking Down Packet Loss

So now we know that bandwidth is how many packets you can stuff in your pipe and that latency is the delay, and that packet loss can adversely affect both. So, in general, when trying to track down network "slowness", you should be looking for packet loss. But this can get kind of tricky because packet loss is random. So, you might actually be getting packet loss at hop #2, but with the default 3 probes per hop, maybe all 3 will get back OK. Then at later hops you will start noticing the packet loss that really occurs at hop #2, but it might look like it's occurring at hop #3. So, it's usually better to do more than 3 probes per hop.

Let's try to debug a bad traceroute and see what might be causing the problem. So as to not try to make any other specific ISP look bad, some hostnames and IP addresses will be changed to protect the innocent. Let's say you're connected to GeoNet via a T1, and you have another office in Chicago that is connected via a different ISP. One day you notice some definite slowness in transferring files and/or logging into machines at the remote site and you want to see where the problem lies. So you decide to do some traceroutes. A traceroute from your GeoNet connected office shows you:
traceroute to chicago4.mycompany.com (342.5.133.4): 1-30 hops, 38 byte packets
 1  router.SanFrancisco.mycompany.com (209.0.0.278)  3.52 ms  2.75 ms  2.63 ms
 2  some_interconnect.geo.net (166.90.420.231)  71.5 ms  3.71 ms  3.5 ms
 3  SF-core1-h1.geo.net (166.90.1.17)  3.23 ms  3.20 ms  3.25 ms
 4  MAE-West-h0.geo.net (166.90.1.34)  7.30 ms  13.7 ms  6.33 ms
 5  mae-west.other-isp.net (198.32.136.256)  21.0 ms  31.4 ms  29.7 ms
 6  core2.SanFrancisco.other-isp.net (254.70.100.245)  21.44 ms  32.2 ms  32.5 ms
 7  core1.Denver.other-isp.net (254.70.40.229)  73.1 ms  *  97.4 ms
 8  border3.Chicaco.other-isp.net (254.70.56.23)  62.3 ms  86.23 ms 53.88 ms
 9  my-company-t1.Chicago.other-isp.net (254.70.111.34)  120.43 ms  95.3 ms  86.44 ms
10  router.Chicago.other-isp.net (342.5.133.1)  *  *  112.42 ms
11  chicago4.mycompany.com (342.5.133.4)  132.34 ms  *  104.12 ms
So looking at this traceroute, you can see that there is some packet loss, but it's hard to tell exactly where it starts. It could be the link between hops 6 and 7, but it's hard to know for sure. So, being an educated tracerouter, you decide to do a traceroute from Chicago back to your office in San Francisco. You get:
traceroute to sf13.mycompany.com (209.0.0.267): 1-30 hops, 38 byte packets
 1  router.Chicago.other-isp.net (342.5.133.1)  3.85 ms  2.64 ms  4.15 ms
 2  my-company-t1.Chicago.other-isp.net (254.70.111.33)  5.16 ms  3.94 ms  7.22 ms
 3  border3.Chicaco.other-isp.net (254.70.56.23)  3.62 ms  4.28 ms  5.15 ms
 4  core1.Denver.other-isp.net (254.70.40.229)  25.8 ms  27.2 ms  23.7 ms
 5  core2.SanFrancisco.other-isp.net (254.70.100.245)  141.0 ms  *  49.7 ms
 6  pb-nap.geo.net (198.32.128.24)  123.43 ms  *  76.22 ms
 7  SF-rt3-f0.geo.net (166.90.354.7)  *  94.12 ms  102.32 ms
 8  some_interconnect.geo.net (166.90.420.232)  85.24 ms  *  97.3 ms
 9  sf13.mycompany.com (209.0.0.267)  117.31 ms  234.42 ms  99.19 ms
So now you have more to go on. First of all you see that this route is an asymettric one. The first route is 11 hops and the route back is 9 hops. Now the number of hops doesn't make any significant difference in how fast your connection is, but it can make things like packet loss and latency increases appear to be occur between two hops when it really isn't there. This is because the packet loss or increase in latency might be between two hops you don't even see because the route back to you is completely different.

So now you can make an educated guess as to where the packet loss might be occurring. Based on the first traceroute, it looked like the bad link might be between core2.SanFrancisco.other-isp.net and core1.Denver.other-isp.net, and by looking at the route back in the other direction, it appears that this assumption might be correct. At this point, your best bet it to copy and paste your traceroutes and get these sent to the appropriate NOC (Network Operations Center). With this type of information, you will now have a lot better chance of tracking down the problem than if you just sent an e-mail saying "my connection to my Chicago office is slow." It also gives you a better understanding of how traffic is exchanged on the Internet.

Summary

In summary, traceroute is a network diagnostic tool that will show you the hops your Internet traffic takes from your host to a remote location. It will also tell you how long it takes for packets to get from your host to each hop as well as if packets get lost along the way, which can be useful in tracking network problems. Since routes on the Internet are often asymmetric, it's usually a good idea to do traceroutes in both directions if possible when trying to debug network slowness. In doing so, you can provide your ISP with crucial information that can help them to fix the network problem.

Postfix 1

Notes:
SMTP creates guidelines for servers so that they can break up and transmit mail messages.                     .
SMTP roughly works as follows: when sending out a mail message with your mail client, all the
different parts (sender, recipient, message body, ...) are put together in the form of text strings. These
strings are separated by code words that SMTP can interpret so it knows what the "To:" address is,
what the "Subject" is and what the "Message Body" contains. SMTP then looks at the "To:" addres(ses)
and breaks it up into the user part (before the @) and the domain part (after the @). With this
information, SMTP knows to which outside SMTP server to connect to deliver the mail. The receiving
SMTP server in turn knows all the different parts and uses the simple commands to see if it knows the
user that is in the "To:" part. If the user is known it will deliver the mail into the correct endpoint. When
the user retrieves his/her mail with a mail client, that client, in turn, understands in which field to put
which text when you are displaying the mail on your screen.
In our factory analogy the SMTP daemon is the workstation sitting between the outside of our factory
and the start and endpoint of our conveyor belt
. The factory has many gates on which things can be
delivered or sent, but the SMTP workstation sits at gate 25.

here domain name=sherpa.com
Hostname = mail.sherpa.com
ip addr =192.168.0.100
to test
#hostname -s | -d | -f
s = short
d = domain
f = fqdn
  
STEP 1configure dns:
1 configure /etc/named.conf
 2 . configure zone files

3 Configure your /etc/resolve.conf to use your DNS server

########################################################
Aliases
1 One to many or list alises
edit /etc/aliases
eg, add
sales2:      hari,ram,user1,jack,pack,mack
save/exit
#newaliases                   //this will update aliases.db aliease database file do ls -l | grep aliases to see changes
use mutt and send mail to sales2 or sales2@sherpa.com and see these defined user get the msg.
2. one to one
eg.  postfix: root
manager: bossco
in total there are 5..

############################################################################
yum install dovecot
vi /etc/dovecot/dovecot.conf
line
21 protocols = imap pop3
33 login_greeting = this is selflearning lab.

vim  /etc/dovecot/conf.d/10-auth.conf
 11 disable_plaintext_auth = no
97 auth_mechanisms = plain login

vim  /etc/dovecot/conf.d/10-mail.conf
 24    mail_location = maildir:~/Maildir
vi /etc/dovecot/conf.d/10-master.conf

enable imap and pop 3 ports and
check following
 75 service auth {
 76   # auth_socket_path points to this userdb socket by default. It's typically
 77   # used by dovecot-lda, doveadm, possibly imap process, etc. Its default
 78   # permissions make it readable only by root, but you may need to relax these
 79   # permissions. Users that have access to this socket are able to get a list
 80   # of all usernames and get results of everyone's userdb lookups.
 81   unix_listener auth-userdb {
 82     mode = 0600
 83     user = postfix
 84     group = postfix
 85   }

save exit
yum install dovecot
vi /etc/dovecot/dovecot.conf
line
21 protocols = imap pop3
33 login_greeting = this is selflearning lab.

vim  /etc/dovecot/conf.d/10-auth.conf
 11 disable_plaintext_auth = no
97 auth_mechanisms = plain login

vim  /etc/dovecot/conf.d/10-mail.conf
 24    mail_location = maildir:~/Maildir
vi /etc/dovecot/conf.d/10-master.conf

enable imap and pop 3 ports and
check following
 75 service auth {
 76   # auth_socket_path points to this userdb socket by default. It's typically
 77   # used by dovecot-lda, doveadm, possibly imap process, etc. Its default
 78   # permissions make it readable only by root, but you may need to relax these
 79   # permissions. Users that have access to this socket are able to get a list
 80   # of all usernames and get results of everyone's userdb lookups.
 81   unix_listener auth-userdb {
 82     mode = 0600
 83     user = postfix
 84     group = postfix
 85   }

save exit

[root@mail conf.d]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK this is selflearning lab.
user ram
+OK
pass redhat
+OK Logged in.
list
+OK 4 messages:
1 522
2 517
3 569
4 2323
.
retr 4
...
quit
telnet localhost 143   for testing imap

For our TLS to work we need at least two files a KEY file and CERTIFICATE file these file should be in PEM format

   to generate our own certificate and key   
openssl req -new -x509 -days 3650 -nodes -out /etc/postfix/certs/cert.pem -keyout /etc/postfix/certs/key.pem

configure centos6.4 dvd yum repo
and
rpm -i http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
and
yum install postgresql93-server postgresql93-contrib

[root@mail data]# pwd
/var/lib/pgsql/9.3/data
[root@mail data]# service postgresql-9.3 initdb
Initializing database:                                     [  OK  ]
[root@mail data]# chkconfig postgresql-9.3 on
[root@mail data]# service postgresql-9.3 start

------------------------------------------------------------------------
[root@mail conf.d]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK this is selflearning lab.
user ram
+OK
pass redhat
+OK Logged in.
list
+OK 4 messages:
1 522
2 517
3 569
4 2323
.
retr 4
...
quit

telnet localhost 143   for testing imap

install postgre from its repo

do #service postgresql-9.3 initdb && service postgrelql-9.3 start && service postgresql-9.3 on 
open up /var/lib/pgsql/9.3/data/pg_hba.conf

80  local        all     all md5   ##change from peer to md5

at end add
host mail        mailreader     127.0.0.1/32     md5
host mail        mailreader     ::1/128     md5

----------------
su postgres
basg 4.1$ psql  <enter>
postgres#alter user postgres password 'abc123';
postgres#\q

service postgres-9.3 restart
psql -U postgres
create user mailreader with password 'nepal123';

revoke create on schema public from public
revoke usage on schema public from public
grant create on schema public from postgres;
grant usage on schema public from postgres;
create database mail with owner mailreader;
\c mail

note: The default style of configuring Postfix mailboxes is to use your Unix user accounts and map them to
mailboxes on your harddrive. Instead of using Unix accounts we will use Postfix's "Virtual Mailbox"
mechanism to tie email and destination on your harddrive together.
<contd switched inside mail database>
$ CREATE TABLE users (
email TEXT NOT NULL,
password TEXT NOT NULL,
realname TEXT,
maildir TEXT NOT NULL,
created TIMESTAMP WITH TIME ZONE DEFAULT now(),
PRIMARY KEY (email)
);

#groupadd -g 1000 email        //adding group 'email' with id 1000
#useradd -g email -u 200 -d /home/mail -s /sbin/nologin mailreader

$ yum install postgresql93-contrib or check rpm -qa | grep postgre

connect to database 'mail'
create extension pgcrypto;
$ INSERT INTO users (
email,
password,
realname,
maildir
) VALUES (
'foo@yourdomain.com',
crypt('ecnrypted_password',gen_salt('bf',5)),
'Foo Lastname',
'foo/'
);

$ CREATE TABLE transports (
domain TEXT NOT NULL,
gid INTEGER UNIQUE NOT NULL,
transport TEXT NOT NULL,
PRIMARY KEY (domain)
);
$ INSERT INTO transports (
domain,
gid,
transport
) VALUES (
'exmaple.com',
1000,
'virtual:'
);
////////for aliases or virtual maps

$ CREATE TABLE aliases (
alias TEXT NOT NULL,
email TEXT NOT NULL,
PRIMARY KEY (alias)
)


And insert some data for demonstration purposes:
$ INSERT INTO aliases (
alias,
email
) VALUES (
'bar@exmaple.com',
'foo@example.com'
);

$ ALTER DATABASE mail OWNER TO mailreader;
Then alter the user for each table in your database:
$ ALTER TABLE users OWNER TO mailreader;
$ ALTER TABLE transports OWNER TO mailreader;
$ ALTER TABLE aliases OWNER TO mailreader;

 better!
But Postfix and PostgreSQL still don't know of each others existence. PostgreSQL is just sitting there,
waiting to be read out, we have to instruct Postfix to get its information not from files but from the
database. This is done by creating mapping files for the different Postfix mechanisms. These files will
hold the queries which will return the necessary information to Postfix. For our setup to work we will
have to create 4 different mapping files for transport, uids, gids, mailboxes.
Lets start with our mailboxes. Postfix needs to know which mailboxes exist so that when it receives
mail on foo@example.com it knows that it can accept it. Instead of writing a database connect
statement and a real query, the mapping files are in a right side and left side syntax.
Open up a new file called mailboxes.cf and put in your database information:
$ user=mailreader
password=secret
dbname=mail
table=users
select_field=maildir
where_field=email
hosts=localhost

save this file in logical directory, the default is
"/etc/postfix/pgsql/mailboxes.cf"
Let continue with the remaining four files. Open up a new file with the name transport.cfand build
your query:
$ user=mailreader
password=secret
dbname=mail
table=transports
select_field=transport
where_field=domain
hosts=localhost
Our third file will be called virtual.cf:
$ user=mailreader
password=secret
dbname=mail
table=aliases
select_field=email
where_field=alias
hosts=localhost
Now that we have our files ready for Postfix, we still need to tell it to use these files to communicate
with PostgreSQL. For making this happen, open up the good old main.cffile from Postfix, go to the
bottom and start telling about PostgreSQL!
$ local_recipient_maps =
virtual_uid_maps = static:200
virtual_gid_maps = static:1000
transport_maps = pgsql:/etc/postfix/pgsql/transport.cf
virtual_mailbox_base = /home/mail
virtual_mailbox_maps = pgsql:/etc/postfix/pgsql/mailboxes.cf
virtual_maps = pgsql:/etc/postfix/pgsql/virtual.cf
mydestination = $mydomain, $myhostname


configure rpmfore for installation of amavis
yum install amavisd-new
yum install clamd





testing email
#telnet localhost 25
....
ehlo localhost
mail from: user01
....OK
rcpt to:user02
..OK
data
...
this is testing mail from user01
quit

#tail -f /var/log/maillog

NFS centos 6.4 "AutoFS" part 2

#####AutoFS#####
*it automatically mounts file systems NFS local SMBFS etc  upon I/O requests.
 autofs-*  rpm must be installed.
 /etc/auto.master - primary configuration file,contains pointer to other configuration
/etc/sysconfig/autofs  -  default startup directives
autofs must be running

now
copy   /etc/auto.misc  which is sample file to  a new file  /etc/auto.shares like defined above.
and edit auto.shares like below



 #service autofs reload

Make sure iptables has allowed the nfs ports( see part 1)
try accessing your /shares/nfs_share now (Success!!)

NFS centos 6.4 Part 1

NAS (Network Area Storage) -preformatted folder/file system is exported eg. Samba/cifs, NFS.
======================================================================
Common Confusion
Block Level vs File Level Storage.
Block level eg. SAN  In its most basic form, think of block level storage as a hard drive in a server except the hard drive happens to be installed in a remote chassis and is accessible using Fibre Channel or iSCSI.
 File level storage devices are often used to share files with users. By creating a block-based volume and then installing an operating system and attaching to that volume, you can share files out using that native operating system. Remember, when you use a block-based volume, you're basically using a blank hard drive with which you can do anything.
File level use cases are generally:
  • Mass file storage. When your users simply need a place to store files, file-level devices can make a lot of sense.
  • VMware (think NFS). VMware hosts can connect to storage presented via NFS in addition to using block level storage.
Block Level Storage uses : -
  • Databases. This is especially true when you want to cluster databases, since clustered databases need shared storage.
  • Exchange. Although Microsoft has made massive improvements to Exchange, the company still does not support file level or network-based (as in, CIFS or NFS) storage. Only block level storage is supported.
  • VMware. Although VMware can use file level storage via Network File System (NFS), it's very common to deploy VMware servers that use shared VMFS volumes on block level storage.
  • Server boot. With the right kind of storage device, servers can be configured to boot from block level storage.

 ------------------------------------------------------------------------------------------------------------------------
Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems allowing a user on a client computer to access files over a network in a manner similar to how local storage is accessed.
it relies on RPC port mapper service which dynamically allocate ports. rpc convert normal operation like rw,change permission etc to remote action.
feautures:-
  • transparent access to remote file system ~ clients are unaware that files are distributed and can access them in the same way as local files are accessed.
  • supports version 2,3,4
  • support tcp and udp
  • finete number of connections between client/server
  • dynamic ports allocation may not always work due to firewalls. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IP address of this LAB NFS Server is 192.168.0.11
#yum install nfs-utils    //includes both clientserver pkgs
#chkconfig rpcbind on
#service rpcbind start
#service nfs start && chkconfig nfs on

to configure specific ports for rpc and nfs to listen to =>
#vim /etc/sysconfig/nfs
search for word "PORT" and uncomment them

[root@server5 ~]#service nfs restart
[root@server5 ~]#service nfslock restart   //to unlock locked ports if held by clients
 
to look rpc and nfs services and ports program id 
[root@server5 ~]#rpcinfo -p localhost          // -p = probe,display list of all registered RPC programmes
if you want to make query from client
[root@Client ~]#/etc/init.d/rpcbind start
[root@Client ~]#rpcinfo -p <nfsserver ip> //to check ports if opened
-----------------------------------------------------------------------------------------------------
now allow ports through iptables

[root@server5 ~]#iptables -I INPUT -m state --state NEW -p tcp -m multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT
[root@server5 ~]#iptables -I INPUT -m state --state NEW -p udp  -m multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT
OR--------------------------------------
[root@server5 ~]#iptables -N NFS
[root@server5 ~]# iptables -I NFS -m state --state NEW -p tcp -m multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT
[root@server5 ~]# iptables -I NFS -m state --state NEW -p udp -m multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT
[root@server5 ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
-------------------------------------------------------------------------------------------------------
#mkdir /nfs_share
#vim /etc/exports                   //we share nfs directory in this file
/projectx *(rw)                                          // rw export to all  clients having our ip access (careful!)
/projecty  192.168..0.100(rw) 192.168.0.101(ro)           //rw=readwrite  ro=readonly
/shared 192.168.0.103(ro,root_squash)                       //root_squash= root client cant write and is by default
/nfs_share 192.168.0.100(rw)
----------------------------------------------------------------------------------------------------
[root@server5 ~]#exportfs -r                      //refresh exports
[root@server5 ~]#exportfs -v                      //dumps current exports
-----------------------------------------------------------
AT NFS client
[root@Client ~] showmount -e 192.168.0.11    //nfs server ip addr
exportlist for  192.168.0.11
nfs_share *
[root@Client ~]mount -t nfs 192.168.0.11:/nfs_share  /shared_data

permanent mount
 #vim /etc/fstab
192.168.0.11:/nfs_share  /shared_data1   nfs  defaults 0  0
192.168.0.11:/nfs_share2   /shared_data2   nfs  defaults,soft,time=10,retry=2     0  0
                           
 if soft,time=10,retry=2 means any prog trying to access share wont get hang, timeout is 10 sec and retry is 2

 check the mounted dir using df -h or mount
------------------------------------------------------------------


SAMBA part 1

IPConfig
eth1 : 192.168.0.11

#yum install samba*  -y

if you need to share system created directory(let selinux allow you to write )
setsebool   -P   samba_export_all_ro   on

setsebool   -P  samba_export_all_rw   on
 if -P option is given- the value of policy is persistent after reboot , if not then its value is changed temporarily till reboot.
To share home directory of users:-
setsebool   -P   samba_enable_home_dirs   on

To share the folder you have created you must do :-
eg. /myshare , /public/disk1 etc

#chcon   -t   samba_share_t   /myshare
#chcon   -t   samba_share_t  /public/disk1
                //check the selinux status by running "ls -lDZ" for dir and "ls -lZ" for files
In above fig. check the selinux context of Screenshot.png which I drag and dropped from Desktop of root to /pub_drive  directory and when i tried to share.. it failed.the reason was the mis labled selinux context   after changing it  the share was successful. look below:-


Sample  Example :
share a directory /pub_drive which is readable to everyone but writable/readable to the "test1" group.

#vim  /etc/samba/smb.conf
//edit around line 70+
 workgroup = WORKGROUP
server string = ...  //you can leave default
deadtime = 15  //this is optional ,it will treat 15 minutes idle time connection as dead
 netbiosname = sambasamba  // you can put any name,this name can also be used to connect by win clients.
host allow = 192.168.0.  198.167.89.  //here only /24 network of two subnet will be allow to access
invalid user = admin_user   root
max connection = 20  //connections up to 20 is enabled
security = user  //username and its password will be asked
//at end of file or share section
[pub_drive]    //you can give other names
path = /pub_drive
comment = everyone read but test1 gorup write
browseable = yes
writeable = yes
writelist = +test1
printable = no  //optional .it disable to load priint drivers
guestok = no

save/exit

service smb start
check file/dir permissions and make sure /pub_drive is in ownership of group test1 and writeable
eg.
chown  root.test1  /pub_drive/
chmod  775  /pub_drive/
Settingup users
#smbpasswd  -a   ganesh
password: ***********
#usermod -G test1 ganesh

Allow samba and samba client through firewall

Logon into a Windows xp/Vista/7 machine go to run type your samba serveraddress 
\\192.168.0.11
type your username and password....success!!

Check and delete connections (useful for deleting session in cache)
net use              ////to check the session
net use   \\192.168.0.11\IPC$ /delete            ///to delete
eg.

user mod

#useradd -g $GROUP $newUSER

# groupadd NewGroupName

            add secondary groups to a user, with the option “-G”

usermod -G $GROUP $USER 


            You can also remove a use from secondary group with:
 
gpasswd -d $USER $GROUP 

SUID ,SGID ,sticky bit

So what is the sticky bit?

A sticky bit is a permission bit that is set on a directory that allows only the owner of the file within that directory or the root user to delete or rename the file. No other user has the needed privileges to delete the file created by some other user.
This is a security measure to avoid deletion of critical folders and their content (sub-directories and files), though other users have full permissions.

Why does /tmp have the t sticky bit?

The /tmp directory can be used by different Linux users to create temporary files. Now, what if an user deletes/rename a file created by some other user in this directory?
Well, to avoid these kind of issues, the concept of sticky bit is used. So for that a 777 is given but preserving the sticky bit is not a bad idea.
A stickybit is a workaround method for shared directories not to be deleted accidentally. When a directory has a stickybit then only the owner or the root can delete it even that every user can take the full other permissions.
/tmp is the most shared directory between processes and users and for that it contains the stickybit to ensure that no user can delete the directory, even that the permission is 777 , and it must be so to give the ability to the users and processes to use the directory without conflict in permissions.

This usage of the sticky bit only applies to directories, not files.

sticky bit
$ chmod +t directory     or    $ chmod 1754 directory
$ chmod -t directory     or    $ chmod  754 directory
 
 
SGID 
chmod g+s reids.pl or chmod 2755 reids.pl 
$ chmod g-s reids.pl
$ chmod 755 reids.pl
 
SUID 
# chmod u+s /home/venu/reids.pl
To assign SUID in an absolute manner, simply prefix 4 to whatever
octal string you would otherwise use (like 4755 instead of 755) 

Apache webserver 2.2.15.el6 SSL/TLS part 2

how SSL actually works for securing your communications over the Internet. Before the communications occur, the following takes place:
  1. A company wishes to secure communications to their web server company.com.
  2. They create a public and private key for company.com (this is also known as as “SSL Certificate“).
  3. They go to a trusted third party company such as Thawte or Verisign: Thawte makes the company prove its identity and right to use the company.com domain. This usually involves a lot of paperwork and paying a hefty fee.
  4. Once the verification is complete, Thawte gives the company a new public key that has some additional information in it. This information is the certification from Thawte that this public key is for the company and company.com and that this is verified by Thawte. This certification information is encrypted using Thawte’s own private key… we will see why below.
Then, when Jason wishes to communicate with the company at company.com,
  1. Jason makes a connection to company.com with its computer (e.g. from his web browser if this is a web site). This connection is made to a special “port” (address) on company.com that is set up for SSL communications only (alternately, Jason could connect to a non-secure port and the initiate a secure connection after the fact … see SSL vs TLS – what’s the difference).
  2. Jason connects to company.com on its SSL-secured port, the company sends back its public key (and some other information, like what Ciphers it supports).
  3. Jason gets the public key and decides if it is “OK”…
    1. If the public key has expired, this could be a problem (these are only valid for a certain number of years before they have to be re-verified)
    2. If the public key claims to be for some domain that is not company.com that could be a significant problem.
    3. Jason has the public key for Thawte (and many other third party companies) stored in its computer — because these come with the computer. Thus, Jason can decrypt the validation information, prove the validation is actually from Thawte, and verify that the public key is certified by Thawte. If Jason trusts Thawte, then he can trust that he is really communicating with Company. If Jason doesn’t trust Thawte, or whatever Third Party verification company is actually being used, then the identity of who is running the servers to which Jason is connecting is suspect.
  4. If Jason doesn’t trust the server, then the communication is terminated before anything sensitive is communicated.
    1. Note: If Jason has his own SSL certificate, he may send that to the server at this point to see if the server trusts Jason.  These “Client-side SSL certificates” are not commonly used, but provide a good way for users like Jason to authenticate themselves with a server without using a username or password (or in addition to doing so, as a second factor).  In cases where this is used, the server would have to already know about the Jason’s certificate and verify it in a similar way to how the client verified the server.  If this fails, the connection is terminated.  If a client-side certificate is not needed, this step is skipped.
  5. Once Jason is happy with the server (and the server with Jason, if needed), then he can  choose an SSL Cipher to use from the list of encryption methods provided by the server, and generates a “symmetric key” (a password) for use with that Cipher.  Jason encrypts this password using the server’s public key and sends it back to the server.  The server (and only the server) can decrypt this message and get this password, which is now shared by both Jason and server.
  6. Jason will then start communicating with the company by encrypting all data using this password and the chosen Cipher.  Normal “symmetric” (password-based) encryption takes place from this point forward because it is much faster than using the public and private keys for everything. These keys were needed to enable the company (and possibly Jason to prove its identity and right to domain.com and to enable Jason and server to generate and securely communicate the unique, shared password.
SSL vs TLS
Transport Layer Security (TLS) and its predecessor, Secure Sockets Layer (SSL), are cryptographic protocols which are designed to provide communication security over the Internet. They use X.509 certificates and hence asymmetric cryptography to assure the counterparty whom they are talking with, and to exchange a symmetric key. This session key is then used to encrypt data flowing between the parties
There are two distinct ways that a program can initiate a secure connection with a server:
  1. By Port: Connecting to a specific port means that a secure connection should be used.  For example, port 443 for https (secure web), 993 for secure IMAP, 995 for secure POP, etc.  These ports are setup on the server ready to negotiate a secure connection first, and do whatever else you want second.
  2. By Protocol: These connections first begin with an insecure “hello” to the server and only then switch to secured communications after the handshake between the client and the server is successful. If this handshake fails for any reason, the connection is severed.  A good example of this is the command “STARTTLS” used in outbound email (SMTP) connections.
The “By Port” method is commonly referred to as “SSL” and the “By Protocol” method is commonly referred to as “TLS” in many program configuration areas.  Sometimes, you have only the option to specify the port and if you should be making a secure connection or not and the program itself guesses from that what method should be used … many old email programs like Outlook and Mac Mail did th
To Review: In email programs and other systems where you can select from SSL or TLS together with the port a connection will be made on:
  1. SSL means a “by port” connection to a port that expects to the session to start with security negotiation
  2. TLS means a “by protocol” connection where the program will connect “insecurely” first and use special commands to enable encryption
  3. Use of either could result in a connection encrypted with either SSL or TLS of any version based on what is installed on the sever and what is supported by your program.
  4. Both methods of connection result in equally secure communications.

So then, should I choose TLS or SSL?

If you are configuring a server, you should install software that supports the latest version of the TLS standard, and configure it properly.  This ensures that the connections that your user make is as secure as possible.  Using an excellent security certificate will also help a lot — e.g. one with 2048+ bit keys, Extended Validation, etc.
 current vers:
TLS 1.2 was defined in RFC 5246 in August 2008.
 From a security standpoint, SSL 3.0 should be considered less desirable than TLS 1.0. The SSL 3.0 cipher suites have a weaker key derivation process; half of the master key that is established is fully dependent on the MD5 hash function, which is not resistant to collisions and is, therefore, not considered secure. Under TLS 1.0, the master key that is established depends on both MD5 and SHA-1 so its derivation process is not currently considered weak

Basic TLS handshake

A simple connection example follows, illustrating a handshake where the server (but not the client) is authenticated by its certificate:
  1. Negotiation phase:
    • A client sends a ClientHello message specifying the highest TLS protocol version it supports, a random number, a list of suggested CipherSuites and suggested compression methods. If the client is attempting to perform a resumed handshake, it may send a session ID.
    • The server responds with a ServerHello message, containing the chosen protocol version, a random number, CipherSuite and compression method from the choices offered by the client. To confirm or allow resumed handshakes the server may send a session ID. The chosen protocol version should be the highest that both the client and server support. For example, if the client supports TLS1.1 and the server supports TLS1.2, TLS1.1 should be selected; SSL 3.0 should not be selected.
    • The server sends its Certificate message (depending on the selected cipher suite, this may be omitted by the server).[102]
    • The server sends a ServerHelloDone message, indicating it is done with handshake negotiation.
    • The client responds with a ClientKeyExchange message, which may contain a PreMasterSecret, public key, or nothing. (Again, this depends on the selected cipher.) This PreMasterSecret is encrypted using the public key of the server certificate.
    • The client and server then use the random numbers and PreMasterSecret to compute a common secret, called the "master secret". All other key data for this connection is derived from this master secret (and the client- and server-generated random values), which is passed through a carefully designed pseudorandom function.
  2. The client now sends a ChangeCipherSpec record, essentially telling the server, "Everything I tell you from now on will be authenticated (and encrypted if encryption parameters were present in the server certificate)." The ChangeCipherSpec is itself a record-level protocol with content type of 20.
    • Finally, the client sends an authenticated and encrypted Finished message, containing a hash and MAC over the previous handshake messages.
    • The server will attempt to decrypt the client's Finished message and verify the hash and MAC. If the decryption or verification fails, the handshake is considered to have failed and the connection should be torn down.
  3. Finally, the server sends a ChangeCipherSpec, telling the client, "Everything I tell you from now on will be authenticated (and encrypted, if encryption was negotiated)."
    • The server sends its authenticated and encrypted Finished message.
    • The client performs the same decryption and verification.
  4. Application phase: at this point, the "handshake" is complete and the application protocol is enabled, with content type of 23. Application messages exchanged between client and server will also be authenticated and optionally encrypted exactly like in their Finished message. Otherwise, the content type will return 25 and the client will not authenticate.

Client-authenticated TLS handshake

The following full example shows a client being authenticated (in addition to the server like above) via TLS using certificates exchanged between both peers.
  1. Negotiation Phase:
    • A client sends a ClientHello message specifying the highest TLS protocol version it supports, a random number, a list of suggested cipher suites and compression methods.
    • The server responds with a ServerHello message, containing the chosen protocol version, a random number, cipher suite and compression method from the choices offered by the client. The server may also send a session id as part of the message to perform a resumed handshake.
    • The server sends its Certificate message (depending on the selected cipher suite, this may be omitted by the server).[102]
    • The server requests a certificate from the client, so that the connection can be mutually authenticated, using a CertificateRequest message.
    • The server sends a ServerHelloDone message, indicating it is done with handshake negotiation.
    • The client responds with a Certificate message, which contains the client's certificate.
    • The client sends a ClientKeyExchange message, which may contain a PreMasterSecret, public key, or nothing. (Again, this depends on the selected cipher.) This PreMasterSecret is encrypted using the public key of the server certificate.
    • The client sends a CertificateVerify message, which is a signature over the previous handshake messages using the client's certificate's private key. This signature can be verified by using the client's certificate's public key. This lets the server know that the client has access to the private key of the certificate and thus owns the certificate.
    • The client and server then use the random numbers and PreMasterSecret to compute a common secret, called the "master secret". All other key data for this connection is derived from this master secret (and the client- and server-generated random values), which is passed through a carefully designed pseudorandom function.
  2. The client now sends a ChangeCipherSpec record, essentially telling the server, "Everything I tell you from now on will be authenticated (and encrypted if encryption was negotiated). " The ChangeCipherSpec is itself a record-level protocol and has type 20 and not 22.
    • Finally, the client sends an encrypted Finished message, containing a hash and MAC over the previous handshake messages.
    • The server will attempt to decrypt the client's Finished message and verify the hash and MAC. If the decryption or verification fails, the handshake is considered to have failed and the connection should be torn down.
  3. Finally, the server sends a ChangeCipherSpec, telling the client, "Everything I tell you from now on will be authenticated (and encrypted if encryption was negotiated). "
    • The server sends its own encrypted Finished message.
    • The client performs the same decryption and verification.
  4. Application phase: at this point, the "handshake" is complete and the application protocol is enabled, with content type of 23. Application messages exchanged between client and server will also be encrypted exactly like in their Finished message.

CPU Load Average

cmds: top , uptime

         nproc , /proc/cpuinfo
load average: 0.09, 0.05, 0.01 
the three numbers represent averages over progressively longer periods of time (one, five, and fifteen minute averages), and that lower numbers are better. Higher numbers represent a problem or an overloaded machine.
Example traffic on bridge
  • 0.00 means there's no traffic on the bridge at all. In fact, between 0.00 and 1.00 means there's no backup, and an arriving car will just go right on.
  • 1.00 means the bridge is exactly at capacity. All is still good, but if traffic gets a little heavier, things are going to slow down.
  • over 1.00 means there's backup. How much? Well, 2.00 means that there are two lanes worth of cars total -- one lane's worth on the bridge, and one lane's worth waiting. 3.00 means there are three lane's worth total -- one lane's worth on the bridge, and two lanes' worth waiting. Etc.
= load of 1.00
= load of 0.50
= load of 1.70


This is basically what CPU load is. "Cars" are processes using a slice of CPU time ("crossing the bridge") or queued up to use the CPU. Unix refers to this as the run-queue length: the sum of the number of processes that are currently running plus the number that are waiting (queued) to run.
Like the bridge operator, you'd like your cars/processes to never be waiting. So, your CPU load should ideally stay below 1.00. Also like the bridge operator, you are still ok if you get some temporary spikes above 1.00 ... but when you're consistently above 1.00, you need to worry.
The problem with a load of 1.00 is that you have no headroom. In practice, many sysadmins will draw a line at 0.70:

  • The "Need to Look into it" Rule of Thumb: 0.70 If your load average is staying above > 0.70, it's time to investigate before things get worse.
  • The "Fix this now" Rule of Thumb: 1.00. If your load average stays above 1.00, find the problem and fix it now. Otherwise, you're going to get woken up in the middle of the night, and it's not going to be fun.
  • The "Arrgh, it's 3AM WTF?" Rule of Thumb: 5.0. If your load average is above 5.00, you could be in serious trouble, your box is either hanging or slowing way down, and this will (inexplicably) happen in the worst possible time like in the middle of the night or when you're presenting at a conference. Don't let it get there.

    What about Multi-processors? My load says 3.00, but things are running fine!

    Got a quad-processor system? It's still healthy with a load of 3.00.
    On multi-processor system, the load is relative to the number of processor cores available. The "100% utilization" mark is 1.00 on a single-core system, 2.00, on a dual-core, 4.00 on a quad-core, etc.
    If we go back to the bridge analogy, the "1.00" really means "one lane's worth of traffic". On a one-lane bridge, that means it's filled up. On a two-late bridge, a load of 1.00 means its at 50% capacity -- only one lane is full, so there's another whole lane that can be filled.
     = load of 2.00 on two-lane road
    Same with CPUs: a load of 1.00 is 100% CPU utilization on single-core box. On a dual-core box, a load of 2.00 is 100% CPU utilization.


    • The "number of cores = max load" Rule of Thumb: on a multicore system, your load should not exceed the number of cores available.
    • The "cores is cores" Rule of Thumb: How the cores are spread out over CPUs doesn't matter. Two quad-cores == four dual-cores == eight single-cores. It's all eight cores for these purposes.


      Which average should I be observing? One, five, or 15 minute?
      For the numbers we've talked about (1.00 = fix it now, etc), you should be looking at the five or 15-minute averages. Frankly, if your box spikes above 1.0 on the one-minute average, you're still fine. It's when the 15-minute average goes north of 1.0 and stays there that you need to snap to. (obviously, as we've learned, adjust these numbers to the number of processor cores your system has).
To get your cpu info ==> # cat /proc/cpuinfo

.htaccess Use

to use .htaccess
at around line 341 change  
AllowOverride None    to ==>

AllowOverride AuthConfig

saveit

cd outside webdir eg /etc/httpd/conf/ 

#htpasswd -c .htpasswd rambo
password : ******
..................................................................
to add more users like rambo do
#htpasswd .htpasswd  samsung
password:********
.................................................................

Create a file .htaccess in the dir which you want to control web/dir access for example /var/www/html/www.internal.ninja.com/ and add following lines

AuthType Basic
AuthName " Restricted Area Please insert userame password "   ##this will appear in msg box
AuthUserFile /etc/httpd/conf.d/.htpasswd
require valid-user
.............................................
next
#service httpd reload
#httpd -S   (if made on VH)

inheritance and performance issues if used in large scale..