geoip.conf(5)
β¨ geoip.conf(5) β the config file for pam_geoip, bestie edition β¨
okay so you're here because you want your PAM module pam_geoip to know where people are logging in from, and this little file is where you tell it. it's giving β¨access control but make it geographyβ¨. let's go π
π NAME π
geoip.conf β the config file for the PAM module pam_geoip. that's it, that's the name, slay π«Ά
πΈ DESCRIPTION πΈ
so the config file (by default it lives at /etc/security/geoip.conf) is made of lines with four things on them: domain, service, action and location. what do those mean?? keep reading babes, i got you π
when you use the service specific config file, which is /etc/security/geoip.SERVICE.conf, the service column must not be there. and listen β if this file exists, the default file is not used, even if it's sitting right there on the command line as system_file=/file/name. no cap, it just gets ignored π
if you need to match on city names that have non ascii(7) characters (think "DE, KΓΆln" or "SE, VΓ€xjΓΆ"), you can set the character set to use in the module's arguments: "iso-8859-1" or "UTF-8" β and "UTF-8" is the default, periodt β¨
any (sub-)item except for action or the distance matching can use a single asterisk ("*") to match any value. wildcard queen π
π the four items, explained π
domainβ a user name, a group name (prefixed by"@"), or"*"for any user / group. like, everyone's invited or nobody's invited, your call πserviceβ a list of services (or"*") separated by",". and bestie, NO spaces allowed. i said what i said π«actionβ one of"allow","deny"or"ignore". this is literally what gets returned to PAM if the location matches:allowβPAM_ALLOWdenyβPAM_PERM_DENIEDignoreβPAM_IGNORE
locationβ a GeoIP location, separated by";". it can be:- a country code (uppercased, two characters),
"*"or"UNKNOWN" - a country code like above, then
",", then a city name (or"*"). when you're using a GeoIP country database, this part must be"*", i.e. the full entry looks like"DE, *". - a distance from a given point, e.g.
- a country code (uppercased, two characters),
50.0 { 51.513888, 7.465277 }
this one is not available when you're using a GeoIP country database. sad but true π
the location part is allowed to use spaces, but note this: city names must be written exactly as they are in the GeoIP database, i.e. "Mountain View", NOT "Moutain View" and NOT "MountainView". spelling matters, the database is not doing autocorrect for you π
the distance is measured in kilometers. in the example above we're matching a circle of 100 km diameter around Dortmund, Germany β that's 51Β° 30β² 50β³ north, 7Β° 27β² 50β³ east, or (51.513888888889, 7.465277777777876) if you want the numbers. coordinates to the west and to the south get given as negative values. and values must be given in decimal. fr fr π₯
π EXAMPLE π
here's the whole vibe in one block π§
#
# /etc/security/geoip.conf - config for pam_geoip.so
#
#<domain> <service> <action> <location>
@wheel sshd allow DE,* ; SE , Nybro
@wheel sshd allow SE, Emmaboda; SE,VΓ€xjΓΆ
someuser sshd allow 50.0 { 51.513888, 7.465277 }
someuser sshd allow DE,KΓΆln
otheruser sshd allow SE,UmeΓ₯; DK, KΓΈbenhavn
* * ignore UNKNOWN
* * deny *
## END
or the exact same thing as /etc/security/geoip.sshd.conf β notice the service column dipped out because the filename already said sshd π
#<domain> <action> <location>
@wheel allow DE,* ; SE , Nybro
@wheel allow SE, Emmaboda; SE,VΓ€xjΓΆ
someuser allow 50.0 { 51.513888, 7.465277 }
someuser allow DE,KΓΆln
otheruser allow SE,UmeΓ₯; DK, KΓΈbenhavn
* ignore UNKNOWN
* deny *
π¦ SEE ALSO π¦
pam_geoip(8), pam_access(8), pam.d(5), pam(7) β go read these too, iykyk π
π AUTHOR π
Amish - GeoIP2 Hanno Hecker - Legacy GeoIP "<vetinari@ankh-morp.org>" β absolute legends, we love them π«Ά
and that's the whole page bestie!! this one's from 2024-02-05, and it's the geoip.conf(5) manual page. go forth and geo-block responsibly β¨π bye!! π
π¦ where this page comes from
- debian trixie: libpam-geoip 2.1.1-8 Β· BSD-3-Clause
- ubuntu noble: libpam-geoip 2.1.1-8 Β· BSD-3-Clause
- ubuntu questing: libpam-geoip 2.1.1-8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms