Skip to content
May 19, 2025

Pupli

  • .NET
    • .NET Core
    • ASP.NET
    • ASP.NET Blazor
    • ASP.NET MVC
    • ASP.NET Web APIs
    • ASP.NET Worker Services
    • async/await
    • AutoMapper
    • BenchmarkDotNet
    • C#
    • Dapper
    • DateTime
    • Dependency Injection
    • Entity Framework
    • EPPlus
    • FluentEmail
    • gRPC
    • Hangfire
    • HttpClient
    • Identity
    • Image Processing
    • MailKit
    • MassTransit
    • MediatR
    • MessagePipe
    • ML.NET
    • MongoDB
    • NuGet
    • Polly
    • PostgreSQL
    • Protobuf
    • Quartz.NET
    • Resources
    • RestSharp
    • Security
    • Selenium
    • Seq
    • Serilog
    • Sharp7
    • SharpVectors
    • SharpZipLib
    • SignalR
    • SOAP
    • StackExchange.Redis
    • String
    • Syncfusion
    • Windows
    • WPF
    • XML
  • C/C++
    • Qt
  • Database
    • Hibernate
    • MongoDB
    • MySQL
    • PostgreSQL
    • Redis
  • Electrical
    • PLC
  • Go
  • Java
    • Apache POI
    • Gradle
    • Groovy
    • Gson
    • Java
    • Joda
    • Kotlin
    • OkHttp
    • Quartz
    • RxJava
    • Spring
  • JavaScript
    • Express
    • JavaScript
    • Moment.js
    • Mongoose
    • Node.js
    • PM2
    • RxJS
    • Socket.IO
    • TypeScript
    • Yarn
  • Linux
    • Apache
    • Bash
    • Fedora
    • Git
    • Kali
    • Linux
    • Manjaro
    • Nginx
    • SSH
    • Tools
      • Certbot
      • cron
      • cURL
      • DNS
      • FFmpeg
      • GPG
      • grep
      • HAProxy
      • ip
      • iptables
      • Nmap
      • ProxyChains
      • rsync
      • sch
      • Superset
      • systemd
      • ufw
    • Ubuntu
    • VPN
  • Math
    • Formula
  • Microsoft
    • BAT
    • BI
    • Excel
    • PowerShell
    • Windows
      • DNS
    • Windows Server
    • WSL
  • Mobile
    • Android
    • Ionic
  • MQ
    • MQTT
    • RabbitMQ
  • Network
    • Cisco
    • Network+
  • Programming
    • Architectural Patterns
  • Python
    • Bokeh
    • Celery
    • Django
    • dnspython
    • Flask
    • Gunicorn
    • Network
    • NumPy
    • OpenCV
    • openpyxl
    • Pandas
    • PIL
    • psutil
    • PyInstaller
    • PyScreeze
    • PySide
    • pytesseract
    • Python
    • requests
    • Selenium
    • SQLAlchemy
    • SQLite
    • Telegram Bot
    • Virtualenv
    • Windows
  • Tools
    • GitHub Copilot
  • Web
    • Angular
    • Bootstrap
    • HTML
    • Next.js
    • PWA
    • React
    • Tailwind CSS
    • Vite
    • WordPress
    • XPath
    • CSS
Main Menu

Get IPv4/IPv6 Address Range from CIDR in Python

December 29, 2022
import ipaddress

def get_ip_range(cidr):
    net = ipaddress.ip_network(cidr)
    return net[0], net[-1]

cidr = "192.109.82.0/23"
ip_range = get_ip_range(cidr)
start_ip = ip_range[0]
end_ip = ip_range[1]
print("Start ip = ", start_ip)
print("End ip = ", end_ip)
Start ip = 192.109.82.0
End ip = 192.109.83.255

References
https://www.tutorialsbuddy.com/get-ipv4-ipv6-address-range-from-cidr-in-python

Related

Taggedcidrnetworkpython
Copyright © 2025 Pupli.
Powered by WordPress and HitMag.