Python web app with various IP Subnet/CIDR tools.
Download either source or release file and put somewhere on your filesystem.
Poetry is used to build the virtual environment although any other venv tools can be used to build it. Pipx is a good way to install poetry although you can use any of the install methods listed here
poetry install --nodevCopy the examples/env.example to .env in ipwebtools
root folder (not in the package folder.)
Make sure to change the SECRET_KEY and CSRF_SECRET in the .env file
and also set DEBUG=False for a production environment.
Additional information about IP prefixes, IP addresses and ASNs can be gathered from Cloudflare Radar.
CFRADAR_ENABLED=True
CFRADAR_URL=https://api.cloudflare.com/client/v4/radar/
CFRADAR_API_KEY=CFApISecrEtMore information on Cloudflare Radar services are available here. You need to create an API key to use this service by following the get started instructions.
To add additional GeoIP information from Maxmind configure the following:
GEOIP_ENABLED=True
GEOIP_USER_ID=12344
GEOIP_API_KEY=ApISecrEtTo use Maxmind paid service change GEOIP_HOST to geoip.maxmind.com, default host is geolite.info.
# Maxmind paid service
GEOIP_HOST=geoip.maxmind.com# Maxmind Lite service (default)
GEOIP_HOST=geolite.infoMore information on Maxmind services are available here. Testing has only been done with GeoLite2 City database but should work with the paid version.
Run the helper app directly. Use poetry or another virtual environment.
poetry shell
python3 app.pyWith uvicorn.
poetry shell
uvicorn --reload --log-level debug ipwebtools:appWith gunicorn through the uvicorn worker class, this will use gunicorn
default listen address and port. Use -b <LISTEN>:<PORT> to change that.
gunicorn -k ipwebtools.workers.ConfigurableWorker ipwebtools:appCreate a systemd unit file to start the ipwebtools service at startup. An example unit file examples/ipwebtools.service can be used and edited as needed.
cp examples/ipwebtools.service /etc/systemd/system/ipwebtools.serviceEdit the file and change the following as needed WorkingDirectory,
User, Group. Also alter PATH and VIRTUAL_ENV
Environment variables to match your install location.
Make the log directory used by the service (gunicorn logs). Set LOG_DIR in
the .env file to change this if required and change the username to the
same user and group as in the unit file.
mkdir /var/log/ipwebtools/
chown www-data.www-data /var/log/ipwebtools/By default it runs on port 8000 and listens only on localhost. Change
this in the .env file.
Finally enable the service
systemctl daemon-reload
systemctl enable ipwebtools.service
systemctl start ipwebtools.serviceA reverse proxy via Nginix is optional but recommeded step. If the pages are
served under a sub path modify the ROOT_PATH in .env
to match for example ROOT_PATH=/iptools
See examples/nginx.conf and examples/nginx-subpath.conf configuration for a base to get started.