Files
Lee Hanken 7c8efd2228 Initial commit: HPR Knowledge Base MCP Server
- MCP server with stdio transport for local use
- Search episodes, transcripts, hosts, and series
- 4,511 episodes with metadata and transcripts
- Data loader with in-memory JSON storage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 10:54:13 +00:00

252 lines
16 KiB
Plaintext

Episode: 1654
Title: HPR1654: Using AS numbers to identify where you are on the Internet
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1654/hpr1654.mp3
Transcribed: 2025-10-18 06:26:38
---
It's Thursday 4th of December 2014.
This is HPR episode 1654 entitled using as numbers to identify where you are on the internet.
It is hosted by Ken Fallon and is about 20 minutes long.
Feedback can be sent to Ken at Fallon.i or by leaving a comment on this episode.
The summary is, we have run out of shows, we need more now.
This episode of HPR is brought to you by An Honesthost.com.
Get 15% discount on all shared hosting with the offer code HPR15, that's HPR15.
Bet your web hosting that's Honest and Fair at An Honesthost.com.
Hi everybody, my name is Ken Fallon.
And before I get into the day's show, I want to make an appeal for where short of shows.
So we went from a peak during the summer of 45 days, which shows back to back in the queue
down to basically where our show is now.
If we look at it from the point of view of having a few emergency shows in the queue and shows
that Ahuka and Dave have uploaded, we will probably make it to the end of the year, which
would be 7 years of HPR.
Now this has been coming in a while, we've all been hearing a lot from Ahuka and Ahuka
and a lot from 5150, they've been essentially carrying the network.
So if you wish to have HPR continue, then you need to make a commitment and actually send
in some shows.
Is this in the request to send in questions about whether you think this would be a good
show or commitments that I will send in a show?
It's actually uploading shows as all I want to hear about.
I have my own guild strips to manage with shows that I promised, one which was to Enigma
over nearly 9 years ago now, so yes, and I still own one to Peter 64 and many many others.
So let's not promise to do shows, let's just do some shows.
If you listen to Ahuka Public Radio, even if this is your first episode, be aware this
is a community-produced podcast, so it means the people who produce the shows are the
people who are listening to the shows.
If you think that doesn't apply to you, well, it doesn't, if you've submitted a show
in the last 365 days, if you have not, then yes, it applies to you.
So please send in shows.
With that in mind, I wanted to tell you of a cool little thing problem that I had and
how I went about solving it, it might be of interest to you, it might not, who knows.
The problem stated relatively simply is I have mobile devices, laptop to be specific
in phones and that sort of thing, but it's mostly related to my laptop.
Now I take that and I use it here at home.
I use it on the train over a cell network and I use it in work.
In those different places, I also use wired network connections or mobile network connections.
So depending on where I am, I might want to connect to my local NAS at home, I might
want to connect to some work servers, I might want to not make any network connections
because I'm on wireless and I just want to be able to browse the net.
If I'm using a public access point, I might want to make sure that all my traffic gets
routed through a VPN that's slightly sore, but more secure, yeah, yeah, yeah.
We all are familiar with the various different issues.
Computers these days do quite a good job of connecting to the network and discovering,
well, I've got a internet connection or I've got a wire connection and that's basically
where it ends.
So I've had scripts for a long time where I try to identify where I was, what the connection
was and based on the IP range, if I'm on 192168 private range, I'm at home, if I'm on
10, or whatever, whatever, I'm in work and that kind of works, but then it kind of
doesn't because the 10 networks are now used by mobile operators when they're doing their
cellular networks.
So that kind of doesn't work well, then you could look for the MAC addresses and ping various
different devices, but that means you're always pinging redundant devices.
If you're at home, you might be pinging a server in work, if you're in work, you might
be pinging a server at home and they're not going to reply.
So I have to put in timeouts and I think it's ugly and the IP addresses change.
And then I try looking at things like ARP tables, you know, looking at the MAC addresses
of devices, which is unique, but then you need to maintain the list of your devices.
And if the network router in work changes or switches to a backup of your home device breaks,
then you have to go in and edit the script and, you know, it's just a mess.
So I was thinking about this and was thinking, well, there's got to be a better approach
to this whole solution.
And rather than going from the inside out, so, you know, rather than looking at all, I've
been given an IP address on this machine, it's been given from that device and that device
I know happens to be there.
That's kind of unmanageable.
So what I've done now over the last few months is I've thrown that on its head.
The first thing I do is I try and connect to my own server externally and run Opener
page, which is a PHP page with what is my IP.php, which I'll include in the show notes.
And it's basically got three variables.
Well, let's get the IP address is server dollars underscore server remote address.
That's it.
That's all it does under print stat.
I have two other things in there, which I use for myself, but they're not used in the script.
But it prints the IP address.
You make this call, you get the IP address.
Now, if you don't have your own server, you can go to Google or IP check in or IP, what
is my IP address.com and all of these services, I think this is another one, the IP config.me
or something.
And all of these services just send back the IP address.
And when you think about it, it's just a massive invasion of privacy.
It's basically how the internet works when you go to a web page and you want them to send
you something back.
They need to know where you are or they're going to be able to send it back.
It's as simple as that.
And so that's all very well.
So how does that help me?
Well, it at least tells me.
So I ask the server to tell me what IP address that I'm displaying.
So that's good news because it tells me what IP address I am coming out on the public.
So because of the shortage of internet addresses, private ranges have been used.
The 192, the 172 range, not all of the 192, 168 range, and 10, does whatever range have
been used and those are pooled addresses used by organizations and companies and people
in their personal homes.
So rather than having to have a IP address for every device that you have, we have shared
these private address ranges and then those are NASA to the network address translation
through your modem device out to the internet.
So you're only using for all the devices that are in your home, you're only using one IP
address.
That hopefully will all change with IP version six and everybody will be able to talk
to everybody else.
And we'll all be singing company.
Yeah.
And everything will be wonderful.
But as it stands now, that's how that's why you might be a mark and get 192, 168 range
and you might be at home and get 192, 168 range and why you have problems.
Well, what you won't have, if you call the server from home, you will get definitely a
different IP address than you will, if you call the server from work, you will get definitely
a different IP address range.
So that's fantastic problem solved, well done, we can all go home, not 100% true because
the IP address that you're on will change even though it's a single IP address.
When you reboot your router, you will get another one when a work you might have also a pool
of IP addresses that will be shared.
So that's not 100% ideal, really.
What if there was an open source database that you could use freely that would tell you
where the IP address is assigned to, surely this thing cannot exist.
Well, actually, it's been around for a long time.
It's called the GOIP database, actually it's called the GO light country and the GO light
city databases and they're provided free of charge under a patchy ish, if I read it correctly
license and it's by the company max mind.
They also released snippets of code and the sea libraries released under the LGPL, they've
done this for years and there's more than one company based basis they're filtering
on this.
This is typically this type of technology is typically used by people to decide what country
you're in.
So they'll look at your IP address and put the language on to whatever the country is,
which I find immensely frustrating.
Oh, you go to Google, you have everything set you, there's a browser setting that calls
it to a browser that says, give me English and they insist on giving you Dutch, insist.
There's only, there's only some sort of hack around that you can do to turn that off,
but it is really, really annoying.
If somebody sends English in the browser, they should receive English back, but that's
not the case because most operation systems are installed with English here in this country
so you can't, they obviously can't use that, but that's pet peeve, pet peeve.
Other places where you might come across this sort of thing is if you're playing videos
on YouTube, for instance, and it's blocked in your country, then you will, they will have
used a geo, a geo IP address database to look up the IP addresses, might necessarily be
the one from MaxMind, but that sort of thing.
If you ever tried to play a video from the US in Europe, you, and you got one of those,
it is not available in your country, that's what's happening.
Eventually, it would also be, if you come to a European site and you get the EU clicky
privacy policy thing, that's what's happening there as well.
And it's also why, just a little footnote, why Google are, I call it Shenanigans on
Google's implementation of the law that requires them to respect users' privacy because they
know full well where people are physically located and the fact that they're saying they
can't implement their, the legal requirements to do whatever it is that their legal requirement
is based on whether you're inside or outside the EU is Shenanigans.
That's it by the way.
Anyway, my point here is that GOIP is quite useful.
Now, if you yum install GOIP, which I think is already installed on Fedora 20 by default,
or an apt-get install GOIP-bin, it will pull in the GOIP tools.
If you look in user share GOIP, which is capital G and IP, you will see also with the same
camel case lettering, two different databases, one called GOIP.dat and the other GOIP V6.dat
and as you can imagine, one is for resolving IP addresses in the version four and the others
for resolving IP addresses in the version six.
Fantastic.
Very good.
With me, Silver.
Then you can use a tool.
Fedora, it's slightly different, but we'll get to that in a moment.
Then you can use it to call GOIP lookup and use a common IP address, eight.dat.dat, which
is Google and that will give you back GOIP Country Edition US United States.
So you know that that IP address is registered to a company in the United States.
That's all very well.
If I was using an IP address for a company, my company or whatever, and I was registered
that IP address, then the database would show that which city I was coming out of.
If I'm an ISP and providing IP addresses to end customers, then you get the IP address
of the ISP's head office.
So essentially, it means that you get the IP address or whatever provider you happen
to be on.
Maybe this worked out okay because I happen to be on a different provider at home than
I am in work that I would be on the train.
So happiness there.
However, then I discovered on Fedora when I installed GOIP that there was another database
called GOIPASnumber.dat and ASNOM version six.
Now what is ASNOM?
Well the internet gets its name from the word interconnected networks.
And that stands for autonomous, so AS stands for autonomous system.
So how it actually works is every ISP or big company or whatever requests in ASNOM.
And then using various different routing policies, you are able to route between these
using BGP protocols for instance.
So my ISP will have one ASNumber and my work ISP will have another ASNumber and the mobile
provider will have another ASNumber.
So what happens if you do a GOIP look up on Fedora?
You get the same line, 28.8.8, you get GOIP country edition US United States, but you
get an additional line, GOIPASNumber edition with ASNumber AS15169 registered to Google
link.
Pretty cool.
Why is this pretty cool?
Well as it turns out, even if you are with the same internet provider, the chances are
if they are doing DSL or fiber or whatever, they will use a different ASNumber for the DSL,
a different ASNumber for the mobile network and a different ASNumber for whatever.
In a work, we use different ASNumbers for our mobile wireless networks, which are open
to the public.
Or the ones we use for our labs or the ones we use for our desktops, desks, that turns
out to be really, really useful.
Now I will include a script that you can, it's important to know that you can use to update
all these databases, it's important to know that your package manager will not automatically
update these databases.
So you need to run a Chrome job and it's quite simple, I will put a script in for database
in a list of all the GO country lights, the city ones, the IPv6, the ASNumbers and it
downloads that using WGET and it unzips them and pops them into user share GOIP with the
name of the GOIP database.
Now I'm sure Mr. Morris will have a recommendation for how to improve that, but there you go.
So that is that, now that brings me on to how you can use that.
So what I have in the show notes will be a very, very quick script, which first line does
a WGET with a very quick timeout to the location of where my server is and if it's up, I will
then try and get my IP address and then I have a very simple GOIP look up and I basically
grab out the ASNumber and I have a simple case statement and depending on the ASNumber it
says whether I'm at home, I'm at work, I'm on GPS or I'm on a, even on the HPR VPS or
on the GSM network.
So that tells me my location.
And the only other thing I need to do is use IW config for my interfaces to determine
whether I'm wired or wireless.
So then I have a connection is found, my IP address and all that sort of stuff and then
I have a case statement where I have location, dollar location has the variable with an underscore
and underscore type four, whether it's wired or wireless.
And then I do work wired and then all the stuff I want to do for my work wired, work
on the underscore wireless, all the stuff I want to do for that, GSM on the underscore wireless
which obviously is GSM home wired, home wireless.
And what you choose to do with that after that is entirely up to you.
I have, as I said, mounting various different disks and opening VPNs and I mean you might
run your monitor and monitor configuration utilities or if you're a Jesu, you might
have your machine do all sorts of interesting cool stuff, but that's pretty much it.
So not very complicated, it doesn't need to be, it's a regular show.
So now I will bet you a do and work you live do.
I will wish you happy holidays, I guess, is the politically correct thing to say.
Looking up my wife, who's very cold after coming in from shopping.
Okay, tune in tomorrow for another exciting episode of Hack up, I'll be glad you're met
even more excited by the fact it's probably your episode because you felt so guilty that
you've immediately decided not to watch the news tonight and instead record a show
for Hack up Public Radio.
Alright, if I don't see you, I'll talk to you later on in New Year's show.
You've been listening to Hack up Public Radio at HackupublicRadio.org.
We are a community podcast network that releases shows every weekday Monday through Friday.
Today's show, like all our shows, was contributed by an HPR listener like yourself.
If you ever thought of recording a podcast and click on our contributing to find out how
easy it really is, Hackup Public Radio was founded by the Digital Dog Pound and the
Infonomicon Computer Club and is part of the binary revolution at binrev.com.
If you have comments on today's show, please email the host directly, leave a comment on
the website or record a follow-up episode yourself.
Unless otherwise status, today's show is released under Creative Commons, Attribution,
ShareLife, 3.0 license.