Body temperature is regulated by a thermoregulatory centre in the brain, the hypothalamus. The hypothalamus can sense the temperature of the blood via receptors. The skin also contains temperature receptors and sends nervous impulses to the hypothalamus.
If the body is too hot the blood vessels vasodilate and sweat is produced. More blood flows to the skin and the evaporation of sweat causes the skin to become colder. Blood and skin is cooled. If the body is too cold blood vessels vasoconstrict, sweating stops and muscles contract (shiver). This reduces the amount of blood that travels through the skin, prevents heat being drawn from the body, and produces heat in muscles by causes them to contract.