Networking for Security, lesson 3 of 12
Addresses: MAC and IP
Lesson 2 gave every device a working cable and a socket on a switch. Next, each one needs a way to be found. Every camera and controller carries two addresses. One is built in at the factory and never changes. The other is given to it on site. This lesson explains why both exist, how to read them, and what goes wrong when two devices claim the same one.
Two addresses at work
Pick a situation, then play or step through it. Watch the switch's table fill in.
The everyday picture
A car has two identifiers. One is the vehicle identification number stamped into the body at the factory. It stays with that car for life and no other car has the same one. The other is the number of the parking space the car has been given at work. That depends on where the car is, and it changes if the car moves to another building.
The parking attendant works by space number, because space numbers follow a plan: level 2, row C, space 14. Nobody could find a car quickly from its factory number alone. But when it matters which exact car is in the space, the factory number settles it.
A network device has the same two identifiers. The factory number is the MAC address. The space number is the IP address.
The MAC address
The MAC address is burned into the network part of every device when it is made. MAC stands for media access control, which you can forget. What matters is what it looks like and what it is for.
It is written as twelve characters in six pairs, like 00:1A:07:3C:4D:5E. Some makers print it with dashes or with no separators at all. The characters are hexadecimal digits: the numbers 0 to 9 and then the letters A to F, which stand for ten to fifteen. Hexadecimal is only a compact way to write long numbers.
- The first three pairs identify the manufacturer. Every camera from one maker starts with one of that maker's prefixes.
- The last three pairs are a serial number the maker gives to that one unit.
You will find the MAC address printed on a label on the device and on its box. It is used only for delivery inside the local network. A switch reads the MAC addresses on each packet and nothing else. A MAC address never travels past a router.
The IP address
The IP address is the one you type and the one you plan. It is written as four numbers separated by dots, like 192.168.1.10. Each number can be anything from 0 to 255.
The address is not built into the device. Somebody or something gives it out on site, and it has to fit the network the device is plugged into. The left part of the address says which network the device is on, like the level and row of the parking space. The right part says which device. Lesson 4 shows where the dividing line falls.
This is the version of the address almost every security network uses, properly called IPv4. A newer and much longer form, IPv6, exists because the world ran short of IPv4 addresses. You will see it in device menus. Leave it at its default unless the network's owner tells you otherwise.
| MAC address | IP address | |
|---|---|---|
| Looks like | 00:1A:07:3C:4D:5E | 192.168.1.10 |
| Who sets it | The manufacturer | The installer, or the network, on site |
| Changes when the device moves? | No | Usually yes |
| Who reads it | Switches | Routers, and the devices themselves |
| How far it reaches | The local network only | Any network a router can reach |
| What you use it for | Identifying one exact unit | Reaching the device: viewing, setting up, recording |
Check yourself
A camera is taken down from one site and installed at another site with a different network. Which of its addresses will need to change?
Build one number from bits
Why does each of the four numbers stop at 255? Because inside the device each one is stored as eight switches that are either off or on. One such switch is a bit, and eight of them make a byte. Network people call each of the four numbers an octet.
Each bit is worth twice the one to its right: 128, 64, 32, 16, 8, 4, 2 and 1. Add up the ones that are switched on and you have the number. All eight on gives 255. A whole IP address is four octets, so 32 bits. You will need this picture in lesson 4.
Eight bits make one number
Click a bit to switch it between 0 and 1.
Private and public addresses
Three ranges of addresses are set aside for use inside buildings. They are called private addresses. Anyone may use them without asking, and the same ones are reused in millions of buildings, because they are never seen on the internet. Nearly every camera and controller you install will have one.
| Range | Typical use |
|---|---|
| 10.0.0.0 to 10.255.255.255 | Large organizations with many sites |
| 172.16.0.0 to 172.31.255.255 | Medium networks. Less common |
| 192.168.0.0 to 192.168.255.255 | Small offices, homes and most factory default settings |
| 169.254.0.0 to 169.254.255.255 | Not a planned range. A device gives itself one of these when it asked for an address and nobody answered. Lesson 5 explains |
Everything else is a public address, unique in the world and handed out by internet providers. A building normally has one or a few public addresses on its router, and everything inside shares them. Lesson 11 returns to this when it covers reaching a site from outside.
How the two work together
You tell a recorder to find a camera at 192.168.1.10. The recorder's software thinks in IP addresses. The switch in between delivers by MAC address. Something has to translate.
The translation is done by a short exchange called ARP, the address resolution protocol. The sender broadcasts a question to everyone on the local network: who has 192.168.1.10? The owner answers with its MAC address. The sender writes the pair in a small list it keeps in memory and uses it for the next few minutes before asking again. The second situation in the drawing at the top shows the exchange.
The switch keeps its own, different list: which MAC address was last seen on which port. It builds this by watching the "from" address of every packet that arrives. Nobody sets it up. The first situation in the drawing shows a switch learning.
Both lists depend on one promise: on any one network, each IP address belongs to exactly one device. Break that promise and you get an address conflict. Two devices answer the same question, lists flip back and forth, and both devices drop in and out. The third situation in the drawing shows it. Conflicts are common in security work, because many devices leave the factory set to the same default address. Check the data sheet for the default before you plug in the second unit.
Three examples
Simple: which camera is which?
A technician has mounted twelve identical cameras. The recorder lists twelve devices by IP address, and nothing says which is the loading dock. The technician had photographed each camera's label before mounting it and written the location beside the MAC address. The recorder shows the MAC address next to each IP address, so matching them takes five minutes. Without the photographs it means a ladder and a hand waved in front of each lens.
Medium: the replacement that would not connect
A failed camera is swapped for an identical model and given the same IP address. It powers up, but no video arrives. The site's managed switch had been set to accept only the old camera's MAC address on that port, a common protection against strangers plugging in. The new camera has a new MAC address, so the switch refused it. The network administrator updated the entry and the video returned. The lesson: an identical model is still a different device.
Advanced: recording that fails every few minutes
All sixteen cameras on a site begin to lose recording for a minute at a time, at random. The cameras, the switch and the recorder all test good. The fault began on the day a technician serviced the intercom.
The technician's laptop had been set by hand to 192.168.1.20 for a job elsewhere, and was left plugged into a spare port. The recorder is also 192.168.1.20. Each time the laptop answered an ARP question, cameras sent their video to the laptop until the recorder answered again. The recorder's own log showed an address conflict warning, with the laptop's MAC address in it. Unplugging the laptop ended the fault. Reading that log first would have saved three hours.
From the field
- Photograph every label before the device goes up. Twenty feet up a pole is a poor place to read a MAC address.
- Keep one device list per site: name, location, MAC address, IP address, switch and port. Hand it over with the job.
- Change a default address one device at a time. Plug in one new unit, give it its planned address, then plug in the next.
- Learn two commands on your laptop.
pingfollowed by an IP address asks a device to answer.arp -ashows the list of IP and MAC pairs your laptop has learned. - Use the prefix as a clue. The first three pairs of an unknown MAC address tell you the maker, which is often enough to work out what the mystery device is.
- Set your laptop back to automatic addressing when you leave a site.
Common mistakes
- Plugging in several new devices at once while they all share the same factory default address.
- Typing an address from memory instead of from the site's list, and landing on one already in use.
- Confusing the letter O with the digit 0, or B with 8, when copying a MAC address. Only 0 to 9 and A to F are possible.
- Expecting to find a device by its MAC address from another site. MAC addresses do not cross routers.
- Treating a MAC address as proof of identity. It can be changed in software, so it helps with housekeeping but is not a lock.
Summary
- The MAC address is set at the factory, written as six pairs of hexadecimal digits, and used by switches for local delivery.
- The IP address is given on site, written as four numbers from 0 to 255, and says where the device is in the network plan.
- Each of the four numbers is eight bits. A whole address is 32 bits.
- Addresses starting 10, 172.16 to 172.31, and 192.168 are private and used inside buildings.
- ARP finds the MAC address that goes with an IP address. The switch learns by itself which MAC address is on which port.
- Two devices with one IP address on the same network cause both to fail on and off.
Exercises
Answer each one yourself first, then open the answer.
Exercise 1. Which of these could be a MAC address, and which an IP address? (a) 192.168.300.4 (b) 00:1A:07:9F:22:C1 (c) 10.20.30.40 (d) 00:1G:07:11:22:33
Show answer
Exercise 2. Bits worth 128, 32, 8 and 2 are on, and the rest are off. What is the number?
Show answer
Exercise 3. Is 172.20.5.9 a private address? Is 172.40.5.9?
Show answer
Exercise 4 (think, don't memorize). You add a ninth camera to a site. Within minutes camera 3, which has worked for a year, starts dropping out. Camera 9 also drops out. What is the likely cause, and how do you confirm it without climbing a ladder?
Show answer
arp -a twice a minute apart: if the MAC address beside that IP address changes, two devices are answering. Give camera 9 an unused address from the site list.