
traceroute: see how few hops separate you from anywhere
traceroute -n 1.1.1.1 | tail -n +2 | head -6the internet is smaller than you think
you type in a website, it loads in under a second, and your brain files that under "magic." it's not magic. your traffic is hopping through a chain of routers, usually somewhere between 8 and 20 of them, before it lands wherever it's going. that chain is visible. you can watch it happen in real time from your own terminal, no special tools required.
this matters for defenders because your traceroute path is basically a map of your exposure. every hop is a device that touches your data. every hop is also a clue about your network setup, your isp, and sometimes stuff you didn't know was leaking.
the command
traceroute -n 1.1.1.1 | tail -n +2 | head -6
let's take it apart piece by piece.
traceroute 1.1.1.1 sends packets toward cloudflare's public dns server (1.1.1.1) with a trick built in: it deliberately sets a low "time to live" (ttl) value and increases it with each attempt. every router along the path that the ttl expires at has to reply back with an error message, and that reply is what reveals the router's ip address. it's basically pinging your way outward, one hop at a time, and listening for who answers.
-n tells traceroute not to resolve hostnames, just show raw ip addresses. this makes it run way faster because dns reverse lookups are slow and honestly not needed for a quick check.
| tail -n +2 pipes the output into tail and drops the first line, which is just the header saying "traceroute to 1.1.1.1 (1.1.1.1), 30 hops max." not useful info, just noise.
| head -6 caps the output at 6 lines. traceroute can go on for 15-30 hops depending on the destination, but you usually only care about the first few, that's your home network, your isp, and maybe one or two internet backbone routers.
what the first hop tells you
the very first ip in your output is your router. if that's showing something like 192.168.1.1 or 10.0.0.1, that's normal, that's your local gateway. if you run this from a work laptop and see something unfamiliar or a public ip right at hop one, that's worth understanding, it might mean you're on a vpn, a corporate network, or something got misconfigured with your dhcp.
the second and third hops are usually your isp's equipment. this is a good sanity check spot: if those hops are timing out completely (shown as asterisks), it doesn't always mean trouble, some isps block icmp replies on purpose. but if you're troubleshooting a slow connection, a hop where latency suddenly spikes tells you exactly where the bottleneck lives, and that's ammo for a support call instead of vague "my internet is slow" complaints.
why this is a defensive skill, not a recon trick
yes, attackers use traceroute-style tools to map networks before poking at them. but the flip side is way more useful for you: running this against your own infrastructure tells you what an outsider would see if they mapped you. if you run a small business with a server, tracerouting to your own public ip from an external network (like your phone's hotspot) shows you exactly how many hops and which providers sit between the internet and your box. that's part of understanding your attack surface, not creating one.
it's also a great way to catch weird routing. if your traffic to a normal destination is suddenly bouncing through a country or provider that makes no sense, that can be a sign of a misconfigured route, a compromised router, or in rare cases, traffic being intercepted somewhere upstream. you won't catch that if you never look.
the takeaway
traceroute isn't flashy and it's not going to catch a sophisticated attacker mid-breach. what it does is give you visibility, and visibility is most of defense. run it against your own home network, your own servers, and your own vpn endpoints regularly enough that you know what "normal" looks like. that way when something abnormal shows up, weird hops, sudden latency, unexpected countries in the path, you'll actually notice instead of just assuming the internet is being slow again. protecting your systems starts with knowing exactly what path your data takes to leave them.