| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD module mod_geoip</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center> |
| 11 | <h2><b>ProFTPD module <code>mod_geoip</code></b></h2> |
| 12 | </center> |
| 13 | <hr><br> |
| 14 | |
| 15 | <p> |
| 16 | The <code>mod_geoip</code> module uses the GeoIP library from MaxMind to |
| 17 | look up various geographic information for a connecting client: |
| 18 | <pre> |
| 19 | <a href="http://www.maxmind.com/app/c">http://www.maxmind.com/app/c</a> |
| 20 | </pre> |
| 21 | This information can be used to set access controls for the server. |
| 22 | |
| 23 | <p> |
| 24 | This module is contained in the <code>mod_geoip.c</code> file for |
| 25 | ProFTPD 1.3.<i>x</i>, and is not compiled by default. Installation |
| 26 | instructions are discussed <a href="#Installation">here</a>. |
| 27 | |
| 28 | <p> |
| 29 | The most current version of <code>mod_geoip</code> is distributed with the |
| 30 | ProFTPD source code. |
| 31 | |
| 32 | <p> |
| 33 | This product includes GeoLite data created by MaxMind, available from |
| 34 | <a href="http://www.maxmind.com/">http://www.maxmind.com/</a>. |
| 35 | |
| 36 | <h2>Author</h2> |
| 37 | <p> |
| 38 | Please contact TJ Saunders <tj <i>at</i> castaglia.org> with any |
| 39 | questions, concerns, or suggestions regarding this module. |
| 40 | |
| 41 | <h2>Directives</h2> |
| 42 | <ul> |
| 43 | <li><a href="#GeoIPAllowFilter">GeoIPAllowFilter</a> |
| 44 | <li><a href="#GeoIPDenyFilter">GeoIPDenyFilter</a> |
| 45 | <li><a href="#GeoIPEngine">GeoIPEngine</a> |
| 46 | <li><a href="#GeoIPLog">GeoIPLog</a> |
| 47 | <li><a href="#GeoIPPolicy">GeoIPPolicy</a> |
| 48 | <li><a href="#GeoIPTable">GeoIPTable</a> |
| 49 | </ul> |
| 50 | |
| 51 | <hr> |
| 52 | <h3><a name="GeoIPAllowFilter">GeoIPAllowFilter</a></h3> |
| 53 | <strong>Syntax:</strong> GeoIPAllowFilter <em>filter1 pattern1 [filter2 pattern2 ...]</em><br> |
| 54 | <strong>Default:</strong> <em>none</em><br> |
| 55 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 56 | <strong>Module:</strong> mod_geoip<br> |
| 57 | <strong>Compatibility:</strong> 1.3.3rc1 and later |
| 58 | |
| 59 | <p> |
| 60 | The <code>GeoIPAllowFilter</code> directive is used to configure ACLs based |
| 61 | on the geographic data provided by the GeoIP library. |
| 62 | |
| 63 | <p> |
| 64 | Multiple <code>GeoIPAllowFilter</code> directives in the configuration are |
| 65 | supported; if <b>any</b> filter matches the connecting client, the connection |
| 66 | will be allowed. |
| 67 | |
| 68 | <p> |
| 69 | The <em>filter</em> parameter specifies the GeoIP value to which to apply |
| 70 | the configured <em>pattern</em> for matching. The possible <em>filter</em> |
| 71 | values are: |
| 72 | <ul> |
| 73 | <li><code>AreaCode</code> |
| 74 | <li><code>ASN</code> |
| 75 | <li><code>City</code> |
| 76 | <li><a href="http://www.maxmind.com/en/country_continent"><code>Continent</code></a> |
| 77 | <li><a href="http://www.maxmind.com/en/iso3166"><code>CountryCode</code></a> |
| 78 | <li><code>CountryCode3</code> |
| 79 | <li><code>CountryName</code> |
| 80 | <li><code>ISP</code> |
| 81 | <li><code>Latitude</code> |
| 82 | <li><code>Longitude</code> |
| 83 | <li><code>NetworkSpeed</code> |
| 84 | <li><code>Organization</code> |
| 85 | <li><code>PostalCode</code> |
| 86 | <li><code>Proxy</code> |
| 87 | <li><code>RegionCode</code> |
| 88 | <li><code>RegionName</code> |
| 89 | <li><code>Timezone</code> |
| 90 | </ul> |
| 91 | |
| 92 | <p> |
| 93 | The <em>pattern</em> parameter is <b>case-insensitive</b> regular expression |
| 94 | that will be applied to the specified <em>filter</em> value, if available. |
| 95 | |
| 96 | <p> |
| 97 | Note that as of <code>proftpd-1.3.6rc3</code> and later, the |
| 98 | <code>GeoIPAllowFilter</code> directive can also take a <em>single</em> |
| 99 | parameter which specifies a SQL query (via <code>mod_sql</code>'s |
| 100 | <a href="mod_sql.html#SQLNamedQuery"><code>SQLNamedQuery</code></a>), which |
| 101 | will be used to retrieve the <em>filter</em> and <em>pattern</em> values to use. |
| 102 | |
| 103 | <p> |
| 104 | Examples: |
| 105 | <pre> |
| 106 | # Allow clients with high-speed connections |
| 107 | GeoIPAllowFilter NetworkSpeed corporate |
| 108 | |
| 109 | # Reject clients connecting from North America or South America |
| 110 | GeoIPDenyFilter Continent (NA|SA) |
| 111 | </pre> |
| 112 | The following more complex configuration demonstrates what can be done using |
| 113 | SQL queries: |
| 114 | <pre> |
| 115 | <IfModule mod_sql.c> |
| 116 | ... |
| 117 | SQLNamedQuery get-geo-allowed SELECT "filter_name, pattern FROM allowed_user_geo WHERE user_name = '%u'" |
| 118 | SQLNamedQuery get-geo-denied SELECT "filter_name, pattern FROM denied_user_geo WHERE user_name = '%u'" |
| 119 | </IfModule> |
| 120 | |
| 121 | <IfModule mod_geoip.c> |
| 122 | GeoIPEngine on |
| 123 | |
| 124 | GeoIPAllowFilter sql:/get-geo-allowed |
| 125 | GeoIPDenyFilter sql:/get-geo-denied |
| 126 | </IfModule> |
| 127 | </pre> |
| 128 | The above assumes SQL tables with schema similar to the following (expressed |
| 129 | using SQLite syntax): |
| 130 | <pre> |
| 131 | CREATE TABLE allowed_user_geo ( |
| 132 | user_name TEXT, |
| 133 | filter_name TEXT, |
| 134 | pattern TEXT |
| 135 | ); |
| 136 | |
| 137 | CREATE TABLE denied_user_geo ( |
| 138 | user_name TEXT, |
| 139 | filter_name TEXT, |
| 140 | pattern TEXT |
| 141 | ); |
| 142 | |
| 143 | # Note that we create separate indexes, to allow for multiple rows per user |
| 144 | CREATE INDEX allowed_user_geo_name_idx ON allowed_user_geo (user_name); |
| 145 | CREATE INDEX denied_user_geo_name_idx ON denied_user_geo (user_name); |
| 146 | </pre> |
| 147 | |
| 148 | <p> |
| 149 | <hr> |
| 150 | <h3><a name="GeoIPDenyFilter">GeoIPDenyFilter</a></h3> |
| 151 | <strong>Syntax:</strong> GeoIPDenyFilter <em>filter1 pattern1 [filter2 pattern2 ...]</em><br> |
| 152 | <strong>Default:</strong> <em>none</em><br> |
| 153 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 154 | <strong>Module:</strong> mod_geoip<br> |
| 155 | <strong>Compatibility:</strong> 1.3.3rc1 and later |
| 156 | |
| 157 | <p> |
| 158 | The <code>GeoIPDenyFilter</code> directive is used to configure ACLs based |
| 159 | on the geographic data provided by the GeoIP library. |
| 160 | |
| 161 | <p> |
| 162 | Multiple <code>GeoIPDenyFilter</code> directives in the configuration are |
| 163 | supported; if <b>any</b> filter matches the connecting client, the connection |
| 164 | will be rejected. |
| 165 | |
| 166 | <p> |
| 167 | Note that as of <code>proftpd-1.3.6rc3</code> and later, the |
| 168 | <code>GeoIPDenyFilter</code> directive can also take a <em>single</em> |
| 169 | parameter which specifies a SQL query (via <code>mod_sql</code>'s |
| 170 | <a href="mod_sql.html#SQLNamedQuery"><code>SQLNamedQuery</code></a>), which |
| 171 | will be used to retrieve the <em>filter</em> and <em>pattern</em> values to use. |
| 172 | |
| 173 | <p> |
| 174 | See <a href="#GeoIPAllowFilter"><code>GeoIPAllowFilter</code></a> for |
| 175 | a description of the directive syntax and parameters. |
| 176 | |
| 177 | <p> |
| 178 | <hr> |
| 179 | <h3><a name="GeoIPEngine">GeoIPEngine</a></h3> |
| 180 | <strong>Syntax:</strong> GeoIPEngine <em>on|off</em><br> |
| 181 | <strong>Default:</strong> <em>off</em><br> |
| 182 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 183 | <strong>Module:</strong> mod_geoip<br> |
| 184 | <strong>Compatibility:</strong> 1.3.3rc1 and later |
| 185 | |
| 186 | <p> |
| 187 | The <code>GeoIPEngine</code> directive enables or disables the module's |
| 188 | lookup of geographic information for a connecting client, and subsequent |
| 189 | enforcement of any configured ACLs. |
| 190 | |
| 191 | <p> |
| 192 | <hr> |
| 193 | <h3><a name="GeoIPLog">GeoIPLog</a></h3> |
| 194 | <strong>Syntax:</strong> GeoIPLog <em>file|"none"</em><br> |
| 195 | <strong>Default:</strong> <em>None</em><br> |
| 196 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 197 | <strong>Module:</strong> mod_geoip<br> |
| 198 | <strong>Compatibility:</strong> 1.3.3rc1 and later |
| 199 | |
| 200 | <p> |
| 201 | The <code>GeoIPLog</code> directive is used to specify a log file for |
| 202 | <code>mod_geoip</code>'s reporting on a per-server basis. The <em>file</em> |
| 203 | parameter given must be the full path to the file to use for logging. |
| 204 | |
| 205 | <p> |
| 206 | Note that this path must <b>not</b> be to a world-writable directory and, |
| 207 | unless <code>AllowLogSymlinks</code> is explicitly set to <em>on</em> |
| 208 | (generally a bad idea), the path must <b>not</b> be a symbolic link. |
| 209 | |
| 210 | <p> |
| 211 | <hr> |
| 212 | <h3><a name="GeoIPPolicy">GeoIPPolicy</a></h3> |
| 213 | <strong>Syntax:</strong> GeoIPPolicy <em>"allow,deny"|"deny,allow"</em><br> |
| 214 | <strong>Default:</strong> GeoIPPolicy allow,deny<br> |
| 215 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 216 | <strong>Module:</strong> mod_geoip<br> |
| 217 | <strong>Compatibility:</strong> 1.3.5rc1 and later |
| 218 | |
| 219 | <p> |
| 220 | The <code>GeoIPPolicy</code> directive determines whether the |
| 221 | <code>mod_geoip</code> module will allow a connection by default or not. |
| 222 | |
| 223 | <p> |
| 224 | If <code>GeoIPPolicy</code> is configured using <em>"allow,deny"</em> (which |
| 225 | is the default setting), then the <code>mod_geoip</code> module will allow the |
| 226 | connection, <i>unless</i> the connecting client is rejected by <i>any</i> |
| 227 | <a href="#GeoIPDenyFilter"><code>GeoIPDenyFilter</code></a> rules. |
| 228 | |
| 229 | <p> |
| 230 | If <code>GeoIPPolicy</code> is configured using <em>"deny,allow"</em>, then |
| 231 | the <code>mod_geoip</code> module will <b>reject</b> any connection, |
| 232 | <i>unless</i> the connecting client matches any configured |
| 233 | <a href="#GeoIPAllowFilter"><code>GeoIPAllowFilter</code></a> rules. |
| 234 | |
| 235 | <p> |
| 236 | <hr> |
| 237 | <h3><a name="GeoIPTable">GeoIPTable</a></h3> |
| 238 | <strong>Syntax:</strong> GeoIPTable <em>path</em> <em>[flags]</em><br> |
| 239 | <strong>Default:</strong> <em>None</em><br> |
| 240 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 241 | <strong>Module:</strong> mod_geoip<br> |
| 242 | <strong>Compatibility:</strong> 1.3.3rc1 and later |
| 243 | |
| 244 | <p> |
| 245 | The <code>GeoIPTable</code> directive is used to a GeoIP database file |
| 246 | for use by the GeoIP library. The <em>path</em> parameter given must be the |
| 247 | full path to the database file. |
| 248 | |
| 249 | <p> |
| 250 | If no <code>GeoIPTable</code> directive is configured, then the GeoIP library |
| 251 | will use the default GeoIP Country database file installed with the library. |
| 252 | Otherwise, <b>only</b> the database files configured via <code>GeoIPTable</code> |
| 253 | directives will be used. |
| 254 | |
| 255 | <p> |
| 256 | Multiple <code>GeoIPTable</code> directives can be used to configure |
| 257 | multiple different GeoIP database files for use at the same time. |
| 258 | |
| 259 | <p> |
| 260 | The possible <em>flags</em> values supported are: |
| 261 | <ul> |
| 262 | <li><code>Standard</code> |
| 263 | <p> |
| 264 | Reads the database from the filesystem; uses the least memory but causes |
| 265 | database to be read for each connection. |
| 266 | </li> |
| 267 | |
| 268 | <p> |
| 269 | <li><code>MemoryCache</code> |
| 270 | <p> |
| 271 | Loads the database into memory; faster performance but uses the most |
| 272 | memory. Tables configured with <code>MemoryCache</code> are loaded |
| 273 | into the parent process memory, avoiding the need to read them for |
| 274 | each connection. |
| 275 | </li> |
| 276 | |
| 277 | <p> |
| 278 | <li><code>CheckCache</code> |
| 279 | <p> |
| 280 | Causes the GeoIP library to check for database updates. If the database |
| 281 | has been updated, the library will automatically reload the file and/or |
| 282 | memory cache. |
| 283 | </li> |
| 284 | |
| 285 | <p> |
| 286 | <li><code>IndexCache</code> |
| 287 | <p> |
| 288 | Loads just the most frequently accessed index portion of the database |
| 289 | into memory, resulting in faster lookups than <code>Standard</code> but |
| 290 | less memory usage than <code>MemoryCache</code>. This can be useful |
| 291 | for larger databases such as GeoIP Organization and GeoIP City. |
| 292 | </li> |
| 293 | |
| 294 | <p> |
| 295 | <li><code>MMapCache</code> |
| 296 | <p> |
| 297 | Loads the database into <code>mmap</code> shared memory. |
| 298 | </li> |
| 299 | |
| 300 | <p> |
| 301 | <li><code>UTF8</code> |
| 302 | <p> |
| 303 | Tells the GeoIP library to return UTF8 strings for the data obtained |
| 304 | from this database file. By default, the GeoIP library uses ISO-8859-1 |
| 305 | encoded strings. |
| 306 | </li> |
| 307 | </ul> |
| 308 | Multiple different flags can be configured. |
| 309 | |
| 310 | <p> |
| 311 | Examples: |
| 312 | <pre> |
| 313 | GeoIPTable /path/to/GeoIP.dat MemoryCache CheckCache |
| 314 | GeoIPTable /path/to/GeoISP.dat Standard |
| 315 | GeoIPTable /path/to/GeoIPCity.dat IndexCache |
| 316 | </pre> |
| 317 | |
| 318 | <p> |
| 319 | <hr> |
| 320 | <h2><a name="Installation">Installation</a></h2> |
| 321 | The <code>mod_geoip</code> module requires that the GeoIP library be installed. |
| 322 | For including <code>mod_geoip</code> as a statically linked module: |
| 323 | <pre> |
| 324 | $ ./configure --with-modules=mod_geoip |
| 325 | </pre> |
| 326 | Alternatively, <code>mod_geoip</code> could be built as a DSO module: |
| 327 | <pre> |
| 328 | $ ./configure --with-shared=mod_geoip |
| 329 | </pre> |
| 330 | Then follow the usual steps: |
| 331 | <pre> |
| 332 | $ make |
| 333 | $ make install |
| 334 | </pre> |
| 335 | You may need to specify the location of the GeoIP header and library files in |
| 336 | your <code>configure</code> command, <i>e.g.</i>: |
| 337 | <pre> |
| 338 | $ ./configure --with-modules=mod_geoip \ |
| 339 | --with-includes=/usr/local/geoip/include \ |
| 340 | --with-libraries=/usr/local/geoip/lib |
| 341 | </pre> |
| 342 | |
| 343 | <p> |
| 344 | Alternatively, if your <code>proftpd</code> was compiled with DSO support, you |
| 345 | can use the <code>prxs</code> tool to build <code>mod_geoip</code> as a shared |
| 346 | module: |
| 347 | <pre> |
| 348 | $ prxs -c -i -d mod_geoip.c |
| 349 | </pre> |
| 350 | |
| 351 | <p> |
| 352 | <hr> |
| 353 | <h2><a name="Usage">Usage</a></h2> |
| 354 | |
| 355 | <p> |
| 356 | <b>Access Controls</b><br> |
| 357 | If any <code>GeoIPAllowFilter</code> or <code>GeoIPDenyFilter</code> |
| 358 | directives are configured, the <code>mod_geoip</code> module applies them |
| 359 | against the geographic information retrieved from the GeoIP library. First |
| 360 | any <code>GeoIPAllowFilter</code>s are checked. If <i>any</i> of these |
| 361 | filters matches the connecting client's information, the connection is allowed. |
| 362 | Next, any <code>GeoIPDenyFilter</code>s are checked. If <i>any</i> of these |
| 363 | filters matches the connecting client's information, the connection is closed. |
| 364 | Otherwise, the connection is allowed. |
| 365 | |
| 366 | <p> |
| 367 | This means that if you wanted to reject connections from the US <i>except</i> |
| 368 | for connections from California, you might use something like this: |
| 369 | <pre> |
| 370 | # Deny all connections from the US |
| 371 | GeoIPDenyFilter CountryCode US |
| 372 | |
| 373 | # But allow connections from California |
| 374 | GeoIPAllowFilter RegionCode CA |
| 375 | </pre> |
| 376 | |
| 377 | <p><a name="EnvironmentVariables"></a> |
| 378 | <b>Environment Variables</b><br> |
| 379 | The <code>mod_geoip</code> module will set the following environment |
| 380 | variables whenever a client connects, assuming that the appropriate |
| 381 | GeoIP tables have been configured and the values are known for the connecting |
| 382 | client: |
| 383 | <ul> |
| 384 | <li><code>GEOIP_AREA_CODE</code> |
| 385 | <li><code>GEOIP_ASN</code> |
| 386 | <li><code>GEOIP_CITY</code> |
| 387 | <li><code>GEOIP_CONTINENT_CODE</code> |
| 388 | <li><code>GEOIP_COUNTRY_CODE</code> (<i>two-letter country code</i>) |
| 389 | <li><code>GEOIP_COUNTRY_CODE3</code> (<i>three-letter country code</i>) |
| 390 | <li><code>GEOIP_COUNTRY_NAME</code> |
| 391 | <li><code>GEOIP_ISP</code> |
| 392 | <li><code>GEOIP_LATITUDE</code> |
| 393 | <li><code>GEOIP_LONGITUDE</code> |
| 394 | <li><code>GEOIP_NETSPEED</code> |
| 395 | <li><code>GEOIP_ORGANIZATION</code> |
| 396 | <li><code>GEOIP_POSTAL_CODE</code> |
| 397 | <li><code>GEOIP_PROXY</code> |
| 398 | <li><code>GEOIP_REGION</code> |
| 399 | <li><code>GEOIP_REGION_NAME</code> |
| 400 | <li><code>GEOIP_TIMEZONE</code> |
| 401 | </ul> |
| 402 | These values are also available in the <code>session.notes</code> table, |
| 403 | under keys of the names above. |
| 404 | |
| 405 | <p> |
| 406 | <b>Example Configuration</b><br> |
| 407 | |
| 408 | <pre> |
| 409 | <IfModule mod_geoip.c> |
| 410 | GeoIPEngine on |
| 411 | GeoIPLog /path/to/ftpd/geoip.log |
| 412 | |
| 413 | # Load GeoLite city database into memory on server startup, and use |
| 414 | # UTF8-encoded city names |
| 415 | GeoIPTable /path/to/GeoLiteCity.dat MemoryCache UTF8 |
| 416 | |
| 417 | # Add your GeoIPAllowFilter/GeoIPDenyFilter rules here |
| 418 | </IfModule> |
| 419 | </pre> |
| 420 | |
| 421 | <p> |
| 422 | <b>Logging</b><br> |
| 423 | The <code>mod_geoip</code> module supports different forms of logging. The |
| 424 | main module logging is done via the <code>GeoIPLog</code> directive. |
| 425 | For debugging purposes, the module also uses <a href="../howto/Tracing.html">trace logging</a>, via the module-specific log channels: |
| 426 | <ul> |
| 427 | <li>geoip |
| 428 | </ul> |
| 429 | Thus for trace logging, to aid in debugging, you would use the following in |
| 430 | your <code>proftpd.conf</code>: |
| 431 | <pre> |
| 432 | TraceLog /path/to/ftpd/trace.log |
| 433 | Trace geoip:20 |
| 434 | </pre> |
| 435 | The geographic information retrieved from the GeoIP library for the |
| 436 | connecting client is logged using this "geoip" trace log channel. This trace |
| 437 | logging can generate large files; it is intended for debugging |
| 438 | use only, and should be removed from any production configuration. |
| 439 | |
| 440 | <p> |
| 441 | <b>Suggested Future Features</b><br> |
| 442 | The following lists the features I hope to add to <code>mod_geoip</code>, |
| 443 | according to need, demand, inclination, and time: |
| 444 | <ul> |
| 445 | <li>Configure a message to be sent to rejected clients |
| 446 | <li>Support requiring <i>all</i> <code>GeoIPAllowFilter</code>/<code>GeoIPDenyFilter</code> to apply, in addition to <i>any</i> |
| 447 | </ul> |
| 448 | |
| 449 | <p><a name="FAQ"> |
| 450 | <b>Frequently Asked Questions</b><br> |
| 451 | |
| 452 | <p><a name="GeoIPWhitelist"> |
| 453 | <font color=red>Question</font>: How I can whitelist specific clients from |
| 454 | <code>mod_geoip</code>'s checking?<br> |
| 455 | <font color=blue>Answer</font>: You should be able to easily do this using |
| 456 | <a href="http://www.proftpd.org/docs/howto/Classes.html">classes</a> and the |
| 457 | <code>mod_ifsession</code> module. For example: |
| 458 | <pre> |
| 459 | <Class geoip-whitelist> |
| 460 | From 1.2.3.4 |
| 461 | </Class> |
| 462 | |
| 463 | <IfModule mod_geoip.c> |
| 464 | # Add the normal mod_geoip directives here <b>except</b> <code>GeoIPEngine</code> |
| 465 | </IfModule> |
| 466 | |
| 467 | <IfClass geoip-whitelist> |
| 468 | # Disable mod_geoip for the whitelisted clients |
| 469 | GeoIPEngine off |
| 470 | </IfClass> |
| 471 | |
| 472 | <IfClass !geoip-whitelist> |
| 473 | # Enable mod_geoip for all non-whitelisted clients |
| 474 | GeoIPEngine on |
| 475 | </IfClass> |
| 476 | </pre> |
| 477 | |
| 478 | <p><a name="GeoIPMultipleRules"> |
| 479 | <font color=red>Question</font>: How I can require that a connection match |
| 480 | multiple rules, <i>e.g.</i> both a <code>RegionCode</code> <i>and</i> a |
| 481 | <code>CountryCode</code>?<br> |
| 482 | <font color=blue>Answer</font>: In a given <code>GeoIPAllowFilter</code> or |
| 483 | <code>GeoIPDenyFilter</code>, you can configure a <i>list</i> of |
| 484 | filters/patterns. And <b>all</b> of these filters <b>must</b> be matched, |
| 485 | in order for that <code>GeoIPAllowFilter</code> or <code>GeoIPDenyFilter</code> |
| 486 | to be matched. Thus you can use: |
| 487 | <pre> |
| 488 | # Deny all connections, unless they are explicitly allowed |
| 489 | GeoIPPolicy deny,allow |
| 490 | |
| 491 | # Allow only connections from TX, US |
| 492 | GeoIPAllowFilter RegionCode TX CountryCode US |
| 493 | </pre> |
| 494 | |
| 495 | <p><a name="GeoIPIPv6"> |
| 496 | <font color=red>Question</font>: Does <code>mod_geoip</code> support IPv6?<br> |
| 497 | <font color=blue>Answer</font>: Yes, <em>assuming</em> that the IPv6 |
| 498 | MaxMind tables are configured via <code>GeoIPTable</code>. You can find |
| 499 | the free IPv6 country and city "legacy" files; see this MaxMind <a href="https://www.maxmind.com/en/ipv6-information-and-faq">IPv6 FAQ</a> for details. |
| 500 | |
| 501 | <p><a name="GeoIPPerUser"> |
| 502 | <font color=red>Question</font>: Is it possible to configure <code>mod_geoip</code> to block connections from a geographic region <i>for a specific user</i>?<br> |
| 503 | <font color=blue>Answer</font>: Yes, in conjunction with the <a href="./mod_ifsession.html"><code>mod_ifsession</code></a> module. |
| 504 | |
| 505 | <p> |
| 506 | To do this, you would configure <code>mod_geoip</code> as normal, and then |
| 507 | have an <code><IfUser></code> section like so: |
| 508 | <pre> |
| 509 | <IfModule mod_geoip.c> |
| 510 | GeoIPEngine on |
| 511 | GeoIPLog /var/log/proftpd/geoip.log |
| 512 | GeoIPTable /usr/share/GeoIP/GeoLite2-Country.mmdb |
| 513 | GeoIPPolicy allow,deny |
| 514 | </IfModule> |
| 515 | |
| 516 | <IfModule mod_ifsession.c> |
| 517 | <IfUser baduser> |
| 518 | GeoIPDenyFilter CountryCode CZ |
| 519 | </IfUser> |
| 520 | </IfModule> |
| 521 | </pre> |
| 522 | The <code>mod_geoip</code> modules checks the <a href="#GeoIPAllowFilter"><code>GeoIPAllowFilter</code></a> and <a href="#GeoIPDenyFilter"><code>GeoIPDenyFilter</code></a> directives that are in effect, after a client authenticates. |
| 523 | |
| 524 | <p> |
| 525 | <hr> |
| 526 | <font size=2><b><i> |
| 527 | © Copyright 2010-2023 TJ Saunders<br> |
| 528 | All Rights Reserved<br> |
| 529 | </i></b></font> |
| 530 | <hr> |
| 531 | |
| 532 | </body> |
| 533 | </html> |