|
| 1 | +WHOIS Information and IP Address-Based Geolocation |
| 2 | +================================================== |
| 3 | + |
| 4 | +:date: 2025-09-01 |
| 5 | +:author: Aman Jagotra |
| 6 | +:tags: gsoc, controller, whois, ip, new-features |
| 7 | +:category: gsoc |
| 8 | +:lang: en |
| 9 | +:image_url: https://openwisp.org/images/blog/gsoc25-whois-and-ip-geolocation/gsoc25-whois-and-ip-geolocation.png |
| 10 | +:image_width: 713 |
| 11 | +:image_height: 297 |
| 12 | + |
| 13 | +.. image:: {static}/images/blog/gsoc25-whois-and-ip-geolocation/gsoc25-whois-and-ip-geolocation.png |
| 14 | + :alt: Google Summer of Code, OpenWISP WHOIS Information and IP Geolocation |
| 15 | + :align: center |
| 16 | + |
| 17 | +This summer has been one of the most rewarding experiences of my journey |
| 18 | +as a developer. Over the past three months, I worked on my Google Summer |
| 19 | +of Code project under the mentorship of `Federico Capoano (nemesifier) |
| 20 | +<https://github.com/nemesifier>`_, `Sankalp (codesankalp) |
| 21 | +<https://github.com/codesankalp>`_ and `Kapil Bansal (devkapilbansal) |
| 22 | +<https://github.com/devkapilbansal>`_. The journey was filled with |
| 23 | +challenges, creative problem-solving, and exciting breakthroughs that |
| 24 | +significantly enhanced both my technical and collaborative skills. |
| 25 | + |
| 26 | +About the Project |
| 27 | +----------------- |
| 28 | + |
| 29 | +.. image:: https://img.youtube.com/vi/tQTUJ5MKfTk/maxresdefault.jpg |
| 30 | + :alt: WHOIS Information and IP Geolocation Demonstration Video |
| 31 | + :target: https://youtu.be/tQTUJ5MKfTk |
| 32 | + |
| 33 | +The WHOIS Information and IP Address-Based Geolocation Module enhances |
| 34 | +OpenWISP by enriching device metadata with ownership details and |
| 35 | +approximate geographic location whenever a new public IP address is |
| 36 | +reported. This feature helps administrators improve network visibility, |
| 37 | +identify anomalies, and streamline troubleshooting by providing context |
| 38 | +about IP addresses directly within the OpenWISP platform. |
| 39 | + |
| 40 | +For further details on these features and their functionality within |
| 41 | +OpenWISP, see the documentation pages listed here: |
| 42 | + |
| 43 | +- `WHOIS Lookup |
| 44 | + <https://openwisp.io/docs/stable/controller/user/whois.html>`_ |
| 45 | +- `Estimated Location |
| 46 | + <https://openwisp.io/docs/stable/controller/user/estimated-location.html>`_ |
| 47 | + |
| 48 | +Building WHOIS and IP Geolocation Functionality |
| 49 | +----------------------------------------------- |
| 50 | + |
| 51 | +My work involved tracking the IP addresses reported by devices and using |
| 52 | +it to fetch WHOIS information which included details like organization |
| 53 | +name, ASN, and location details. Using the location details obtained, a |
| 54 | +location linked to the device must be created with clear indication of its |
| 55 | +estimated nature. |
| 56 | + |
| 57 | +Technical Approach |
| 58 | +~~~~~~~~~~~~~~~~~~ |
| 59 | + |
| 60 | +To fetch WHOIS information, I used `geoip2 web service |
| 61 | +<https://geoip2.readthedocs.io/en/latest/#sync-web-service-example>`_ to |
| 62 | +obtain the necessary details. While **django** provides built-in support |
| 63 | +for **geoip2**, at the time of writing this, it supports only database |
| 64 | +based approach (which we will target in the future) and also has limited |
| 65 | +fields available (see: |
| 66 | +https://docs.djangoproject.com/en/5.2/ref/contrib/gis/geoip2/). |
| 67 | + |
| 68 | +I also kept all the related code inside a single folder (``config/whois`` |
| 69 | +and ``geo/estimated-location``) to ensure flexibility, modularity and |
| 70 | +maintainability while also following existing directory and coding |
| 71 | +standards. |
| 72 | + |
| 73 | +Features Implemented |
| 74 | +-------------------- |
| 75 | + |
| 76 | +WHOIS Lookup |
| 77 | +~~~~~~~~~~~~ |
| 78 | + |
| 79 | +.. image:: {static}/images/blog/gsoc25-whois-and-ip-geolocation/whois-details.webp |
| 80 | + :alt: WHOIS Details in OpenWISP |
| 81 | + |
| 82 | +WHOIS is a widely used protocol that provides publicly available |
| 83 | +registration details of IP addresses and domain names. It helps identify |
| 84 | +the organization or individual that owns an IP address, along with related |
| 85 | +information such as the organization name, ASN (Autonomous System Number), |
| 86 | +CIDR block, etc. This data is crucial for network management, security |
| 87 | +auditing, and diagnostics. |
| 88 | + |
| 89 | +To perform a WHOIS lookup, the last reported IP address of a device is |
| 90 | +tracked for changes. When a change is detected, the system performs all |
| 91 | +the necessary checks and fetches asynchronously the WHOIS information |
| 92 | +related to the new IP. Fetched details include organization name, ASN, |
| 93 | +CIDR block, physical address, coordinates and timezone. Since the linking |
| 94 | +of device and WHOIS record is via ip_address, data redundancy is |
| 95 | +minimized. |
| 96 | + |
| 97 | +Functional Highlights: |
| 98 | + |
| 99 | +- **Global Configuration:** The feature can be configured globally as well |
| 100 | + as for individual organizations. |
| 101 | +- **Asynchronous Lookup:** The lookup is done in background asynchronously |
| 102 | + to avoid blocking the main application flow. |
| 103 | +- **Up-to-date WHOIS Information:** The system periodically refreshes |
| 104 | + WHOIS information to ensure it remains current and accurate. |
| 105 | +- **Dedicated Admin Section:** WHOIS details are displayed alongside |
| 106 | + ``last_ip`` in the device admin page for easy access. |
| 107 | +- **REST API:** WHOIS information is included in both device list and |
| 108 | + detail endpoints for API consumers. |
| 109 | + |
| 110 | +**Related Work:** |
| 111 | + |
| 112 | +- `WHOIS Data Retrieval and Storage #1054 |
| 113 | + <https://github.com/openwisp/openwisp-controller/pull/1054>`_ |
| 114 | +- `Show WHOIS Details in the UI #1065 |
| 115 | + <https://github.com/openwisp/openwisp-controller/pull/1065>`_ |
| 116 | +- `Updating stale WHOIS records #1116 |
| 117 | + <https://github.com/openwisp/openwisp-controller/pull/1116>`_ |
| 118 | + |
| 119 | +Estimated Location |
| 120 | +~~~~~~~~~~~~~~~~~~ |
| 121 | + |
| 122 | +.. image:: {static}/images/blog/gsoc25-whois-and-ip-geolocation/estimated-location.webp |
| 123 | + :alt: Estimated Location Feature in OpenWISP |
| 124 | + |
| 125 | +IP-based geolocation estimates the physical location of a device using its |
| 126 | +public IP address. This is achieved by querying reliable IP geolocation |
| 127 | +databases that map IP ranges to real-world locations. The information |
| 128 | +retrieved typically includes country, region, city, coordinates, and |
| 129 | +sometimes the ISP. While not as precise as GPS, it is highly useful for |
| 130 | +network monitoring, compliance, and detecting anomalies such as devices |
| 131 | +connecting from unexpected regions. |
| 132 | + |
| 133 | +Creation of estimated location for the device is done after performing |
| 134 | +WHOIS lookup since location related information (coordinates and address) |
| 135 | +is fetched as part of it. |
| 136 | + |
| 137 | +Functional Highlights: |
| 138 | + |
| 139 | +- **Global Configuration:** The feature can be configured globally as well |
| 140 | + as for individual organizations. |
| 141 | +- **Asynchronous Management:** The creation/update of an estimated |
| 142 | + location is done in background asynchronously to avoid blocking the main |
| 143 | + application flow. |
| 144 | +- **Clear Indicators and status update:** Estimated locations are flagged |
| 145 | + in the admin for manual review, and the status is cleared automatically |
| 146 | + when the address or geometry is updated. |
| 147 | +- **User alerts:** Dispatch web notifications for modifications in |
| 148 | + estimated location. |
| 149 | +- **REST API:** Estimated Status is included in all location related API |
| 150 | + endpoints like location list/detail, device locations etc. The field can |
| 151 | + also be used for filtering results. |
| 152 | + |
| 153 | +**Related Work:** |
| 154 | + |
| 155 | +- `Estimated Location Creation #1067 |
| 156 | + <https://github.com/openwisp/openwisp-controller/pull/1067>`_ |
| 157 | +- `Estimated location: added notification and admin warning #1088 |
| 158 | + <https://github.com/openwisp/openwisp-controller/pull/1088>`_ |
| 159 | +- `Estimated Location: Remove estimated status on manual update #1094 |
| 160 | + <https://github.com/openwisp/openwisp-controller/pull/1094>`_ |
| 161 | +- `Estimated Location: Admin and API filters #1109 |
| 162 | + <https://github.com/openwisp/openwisp-controller/pull/1109>`_ |
| 163 | + |
| 164 | +Current state |
| 165 | +------------- |
| 166 | + |
| 167 | +We are maintaining the ``gsoc25-whois`` branch as parent branch for all |
| 168 | +the WHOIS and IP geolocation features. Once all the PRs are merged and |
| 169 | +features are tested and validated, we can proceed with releasing these |
| 170 | +along with the next release of OpenWISP (Release 1.3). |
| 171 | + |
| 172 | +All the WHOIS feature related PRs are merged to the ``gsoc25-whois`` |
| 173 | +branch except `Updating stale WHOIS records #1116 |
| 174 | +<https://github.com/openwisp/openwisp-controller/pull/1116>`_ which is |
| 175 | +pending review. |
| 176 | + |
| 177 | +The Estimated location feature related PRs `Estimated Location Creation |
| 178 | +#1067 <https://github.com/openwisp/openwisp-controller/pull/1067>`_ and |
| 179 | +`Estimated Location: Admin and API filters #1109 |
| 180 | +<https://github.com/openwisp/openwisp-controller/pull/1109>`_ are also |
| 181 | +pending review. |
| 182 | + |
| 183 | +My Experience |
| 184 | +------------- |
| 185 | + |
| 186 | +My GSoC journey with OpenWISP was an enriching experience that enhanced my |
| 187 | +technical and collaborative skills. I worked closely with an amazing |
| 188 | +community and mentors who provided constant guidance, insightful feedback, |
| 189 | +and encouraged best practices throughout the program. |
| 190 | + |
| 191 | +During this period, I gained hands-on experience with modern technologies |
| 192 | +and development practices, including writing efficient, reusable code, |
| 193 | +implementing automated tests, and improving software reliability through |
| 194 | +iterative development. I also learned the importance of database |
| 195 | +optimization, caching strategies, and integration testing, which deepened |
| 196 | +my understanding of building scalable applications. |
| 197 | + |
| 198 | +Beyond coding, I experienced the true essence of open-source |
| 199 | +collaboration—engaging with the community, understanding real-world use |
| 200 | +cases, and working in an environment where continuous feedback leads to |
| 201 | +better solutions. This journey strengthened my ability to adapt, |
| 202 | +troubleshoot, and deliver high-quality contributions. |
| 203 | + |
| 204 | +What's Next? |
| 205 | +------------ |
| 206 | + |
| 207 | +As my GSoC journey comes to an end, I’m looking forward to building on the |
| 208 | +foundation we’ve created. There are several enhancements planned to make |
| 209 | +these features even more powerful and user-friendly, such as: |
| 210 | + |
| 211 | +- **Database-based WHOIS Lookup:** Adding support for MaxMind databases to |
| 212 | + improve lookup speed and reliability with mechanisms to keep them |
| 213 | + updated without manual effort. |
| 214 | +- **SSID-based Geolocation:** Implementing a feature to determine the |
| 215 | + device's location based on nearby Wi-Fi SSIDs, leveraging external |
| 216 | + services (e.g. Google) for more accurate results. |
| 217 | + |
| 218 | +Beyond these improvements, user feedback will play a key role in |
| 219 | +identifying bugs, edge cases, and areas for refinement, helping us make |
| 220 | +the features more robust over time. |
| 221 | + |
| 222 | +I plan to keep contributing actively to OpenWISP, working on bug fixes, |
| 223 | +adding new enhancements, and supporting new contributors in their |
| 224 | +open-source journey. Now that I have an in-depth understanding of the |
| 225 | +OpenWISP codebase, I’m also interested in maintaining and evolving the |
| 226 | +features I developed during GSoC. |
0 commit comments