Search the Community
Showing results for tags 'ipv4'.
-
import re import struct import socket IPV4PATTERN = re.compile('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$') class InvalidIPError(Exception): pass class IPV4Range: def __init__(self, start, end): ''' Define an IPV4 Range ''' self.start = _validate_ip(start) self.end = _validate_ip(end) self.current = None def next(self): ''' Returns the next ip for this range Returns None if called after reaching end ''' if self.current != self.end: if self.current is not None: self.current = _increase_ip(self.current) else: self.current = self.start else: return False return self.current @staticmethod def knock_on_port(addr, port, timeout=1): ''' Tries to open current addr on given port Returns a tuple (status, error) Where status is boolean and error is an error string or None ''' try: conn = socket.create_connection((addr, port), timeout) except socket.error as e: return (False, str(e)) conn.close() return (True, None) def _validate_ip(addr): if not IPV4PATTERN.match(addr): raise InvalidIPError('%s is no valid IPv4 Addr.' % addr) return addr def _increase_ip(addr): ''' Claculate the next IP Addr ''' return _long2ip(_ip2long(addr) + 1) def _ip2long(addr): return struct.unpack('!L', socket.inet_aton(addr))[0] def _long2ip(long): return socket.inet_ntoa(struct.pack('!L', long)) SCAN.RAR
-
Hello Guys, So, in this topic we are talking about IPv4 Addressing. All of you know about IP Address. but let me give you a small into about IP Address😅😅😅 Let's start today topic!! 💠IP Address: An IP address is a unique address that identifies a device on the internet or a local network. IP stands for "Internet Protocol". Now, we know what is IP address so let's go to the IP addressing: #IPv4 Addressing: 💠Written in dotted-decimal notation like: 🔯10.1.2.3. 🔯 192.172.21.67 💠Each IPv4 address is divided into 4 separated numbers and divided by dots 💠Each of these Division are called octets due to having 8 bits assigned. 💠 32 bits in length. #IPv4 Divided into network and host portion: #Subnet mask define the network portion: Network portion if binary is 1 Host portion if the binary is 0 #Classes of IP address: Default subnet mask assigned by first octet. Classful mask is using default subnet mask. #Define Class of IP Address: 🔥 Note: 127 is skipped between class A and class B. It is a reserved block for the loopback address(127.0.0.1). $Maybe a question arises in your mind that what is the loopback address??? 💠Loopback address: Packets sent to this address never reach the network but are looped through the network interface card only. Can be Used for diagnostic purpose to verify that the internal path through TCP/IP Protocol is working $I hope that you guys understand this!!! #IP Address cam be classify into two major types, here I am talking about types, not about version. Routable(Public) Non-Routable(Private) #Routable IP Address: Publicly Routable IPs are globally managed by "ICANN" @~Internet Corporation for Assigned Name and Number~ @ARIN, LACNIC, AFNIC, APNIC, and RIPE NCC (Groups under ICANN). Public IP's must be purchased before use through your ISP. #Non-Routable IP Address: Private IP cam be used by anyone. Not routable outside your LAN. NAT(Network Address Translation) allows for routing of private IPs through a public IP. #Specialized IP Address: #Loopback address(127.x.x.x.x range): 💠Refer to the device itself and used for testing. 💠 Most commonly used as 127.0.0.1 #Automatic Private IP Addressing(APIPA): 💠 Dynamically assigned by OS when DHCP server is unavailable and address not assigned manually. 💠 Range 169.254.x.x 🔥 Special address ranges never assigned by an administration or DHCP Server I hope you guys understand IP Addressing!!! So, if you want to know more about IPs so stay in tune for a new topic >>> Peace out😁✌️
-
- 1
-
-
- ip
- ip address
-
(and 1 more)
Tagged with: