Re: How to install geoiplookup?

From: Rody <rody_at_dds.nl>
Date: Sat, 08 Jun 2024 01:11:26 UTC
Op vrijdag 7 juni 2024, schreef Edward Sanford Sutton, III:
> On 6/7/24 06:53, Rody wrote:
> > Hi everyone,
> >
> > Trying to prepare myself to get command line geoip lookups working.
> > Running 13.3-RELEASE-p1 of freebsd. It seems the pkg libmaxminddb is
> > installed by default but missing the tools to access the data.
>
> Which tools are missing? My understanding is it is a library for
> accessing the database files once they are downloaded. There are no
> special options to that port (just documentation related) so installing
> from pkg or ports should give identical results for available tools and
> capabilities. Once you have a ports tree, you can check the options of
> that port with `cd /usr/ports/net/libmaxminddb;make showconfig`.
>
> https://www.freshports.org/net/libmaxminddb/ section "This port is
> required by" can help get an idea of other ports using this port; it
> only includes direct dependencies and does not handle dependencies that
> could be changed by changing options in ports.
>
> > The following page tells me to install the libmaxminddb via ports:
> > https://forums.freebsd.org/threads/geoiplookup-for-the-new-geolite2-count
> >ry-db.69866/ But it does not include info for when you've never used ports
> > before.

Ah! I was looking for the old geoiplookup tool as it is currently still named 
on linux. It doesn't exist anymore on bsd though. It is now the new GeoIP2 
software, but I got confused by info from multiple sources as you say further 
down yourself. I compared the files that the port would provide and the files 
I already had installed on my system, and they were the same. Both provided 
the same binary that I did not look for as it was named different from what I 
expected and was looking for. (geoiplookup vs. mmdblookup) The mmdblookuptool 
has different syntax and output but I can use it. After long searching I 
finally came to the conclusion that installing ports was not needed for what 
I wanted with GeoIP. The previous link gave me the wrong impression that a 
ports install of the program would be different from the default program from 
pkg. My bad...

>
> net/geoipupdate is a port that handles fetching the geoip2 databases. It
> is written by maxmind though it is in go instead of c and seems to have
> much more going on for inner workings. If the c version from the forums
> works in beneficial ways over the maxmind copy then maybe it could be
> made into a port for more users to benefit. There have been various
> changes to libmaximdb since that post in 2019 that should be reviewed
> for compatibility.
>
> > The following page tell what to do to get started with ports:
> > https://docs.freebsd.org/en/books/handbook/ports/
> > And tells me that if ports was not installed during install, I should use
> > a series of commands to use git.
> >
> > Not sure if ports was indeed installed or not during install. Any way to
> > find out?
>
> if `ls /usr/ports` is missing/empty then you didn't install it from the
> installer (or moved it); you can get a ports tree and also later update
> the ports tree with git.
>
> > The following page recommends to use portsnap:
> > https://www.cyberciti.biz/faq/install-ports-in-freebsd/
> > Portsnap seems to be installed by default and easier to use, but:
> > https://forums.freebsd.org/threads/portsnap-being-retired-whats-the-alter
> >native.76463/ suggests that maybe only git should be used?
>
> Portsnap is removed from 14+ though it is still present in
> /usr/ports/ports-mgmt/portsnap. Reading its makefile I see
>
> DEPRECATED=     portsnap infrastructure will be removed after the EOL of
> 13.x
> EXPIRATION_DATE=2026-04-30
>
> which tells me the present plan is you would be learning a dead end; it
> will remain a viable option to you until upgrading off of 13. The
> cyberciti.biz article covering portsnap form base for FreeBSD14 when
> updated last month is a bug in that article; its title should remove 14
> or it should include git instructions. The article's content explains
> its steps only got to 13.
> https://www.freebsd.org/releases/14.0R/relnotes/ section about portsnap
> makes that clear for FreeBSD 14+.

Thanks for making that clear to me as I have need for using ports soonish, but 
not for this. 


>
> > Still, it seems the database was already installed automatically using
> > pkg so it should probably be deleted prior to starting with ports?
>
> Ports is the instructions to build and install software. Its install are
> registered as an installed package and the tree is used within a clean
> environment to build the official packages. If you need to change build
> options or need a version that is not in the pkg repo but is in a
> newer/older ports tree then you could build it yourself but otherwise
> the pkg installed version should be the same.
>
> > I imagine the geoiplookup tool is only a tiny binary and requires a lot
> > of work to get it installed this way, or am I missing something?
>
> The ports tree is a collection of 'how to make it work' steps,
> changes/fixes, etc. so getting an entry there is usually how it is made
> easier for FreeBSD users. As for documentation, you tried to follow it
> from multiple places to solve the problems as they arise which usually
> complicates things. Unless there is a known bug, I'd defer to what is in
> the handbook and other official FreeBSD documentation over what is in
> internet blogs and forums when available. The handbook and similar
> documents receives updates and tries to represent how things are
> currently working for what they cover; though not perfect, it is usually
> better than words of a random individual and more up to date than places
> where there may not be an 'edit' button later.

Thanks for making it all much clearer. It's not that hard but got bitten by 
older info that I couldn't place exactly. But it happened before with 
fail2ban. That program has had changes that affected how pf should be 
configured. Many sources available but all explained the old way. Still, I 
found my way in the end...


>
> > Rody