Posts

Showing posts with the label IP

Simple Python function to validate IP address

 Here is a simple Python function that checks if a given string is a valid IP address: import re  def is_valid_ip ( ip ):       pattern = re. compile ( r"^(?:(?: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]?)$" )       return pattern. match (ip) is not None This function uses a regular expression to check if the input string is a valid IP address. The regular expression is compiled and stored in the variable 'pattern'. The match function is used to check if the string passed to the function matches the regular expression. If it does, the function returns True, otherwise, it returns False. You can test the function by calling it and passing a string as an argument: print (is_valid_ip( "192.168.0.1" )) # True   print (is_valid_ip( "256.256.256.256" )) # False Note that this function will only check if the string passed to it is a valid IP address in the format of 'xxx.xxx.xxx.xxx' where x...

VLAN-Transparent Forwarding

Image
VLANs The Ethernet frames that have to be forwarded may reside in different VLANs. This implies that all Ethernet frames contain a (802.1Q) VLAN ID . Communication between different VLANs is not allowed on the link layer. Only routers can make connections between different VLANs. VLANs create thus separated logical Ethernet segments within a single physical segment. Ethernet QoS Ethernet frames optionally contain a (802.1p) user priority indication. If Ethernet QoS is taken into account during bridging, it can be based on two steps: Mapping the user priority of an incoming frame to an internal priority class. This classification can be based on: The type of the interface on which the frame is entering the bridge. The (802.1p) user priority value. The IP Type of Service octet (TOS-byte) for IP packets, using the Precedence or DSCP notation. Sending out the frame while taking into account its internal priority class. This class can be used to: Perform priority queuing on a ...

Convert an IP address to an IP Number

Image
IP address (IPv4 / IPv6) is divided into 4 sub-blocks. Each sub-block has a different weight number each powered by 256. IP number is being used in the database because it is efficient to search between a range of number in database. Beginning IP number and Ending IP Number are calculated based on following formula: IP Number = 16777216*w + 65536*x + 256*y + z (Formula 1) where IP Address = w.x.y.z For example, if IP address is "202.186.13.4", then its IP Number "3401190660" is based on the Formula 1. IP Address = 202.186.13.4 So, w = 202, x = 186, y = 13 and z = 4 IP Number = 16777216*202 + 65536*186 + 256*13 + 4 = 3388997632 + 12189696 + 3328 + 4 = 3401190660 To reverse IP number to IP address, w = int ( IP Number / 16777216 ) % 256 x = int ( IP Number / 65536 ) % 256 y = int ( IP Number / 256 ) % 256 z = int ( IP Number ) % 256 IP Address = w.x.y.z where % is the mod operator and int is return the integer part of the division. In Microsoft Excel you can easily fi...

TCP/IP INVENTION ON JANUARY 1, 1983

TCP/IP,  a milestone invention leading to the modern Internet Internet protocol  suite is the set of communications protocols that implement the protocol stack on which the Internet and most commercial networks run. It has also been referred to as the  TCP/IP  protocol suite, which is named after two of the most important protocols in it: the Transmission Control Protocol (TCP) and the Internet Protocol (IP), which were also the first two  networking protocols  defined. Today's IP networking represents a synthesis of two developments that began in the 1960s and 1970s, namely LANs (  Local Area Networks ) and the Internet, both of which have revolutionized computing.  The Internet Protocol suite—like many protocol suites—can be viewed as a set of layers. Each layer solves a set of problems involving the transmission of data, and provides a well-defined service to the upper layer protocols based on using services from some lower layers. Upper layers...

How to connect Laptop to more than one IP network

Query: How to create dual hardware profile in windows xp pro. Or How to assign two different class ip addresses to single Ethernet card. I have two branch offices with two different ip class. Some of users are roaming (with laptop) and they use to visit both the branch offices frequently. Presently they are manually changing ip address (along with DNS IP) respected with branch ip. Can anyone suggest to get rid of this manually changing process?? The solution which I am looking for is the user can select profile (no windows user profile) and accordingly automatically ip can change. without use of DHCP. Solution: Mobile Net Switch  This program enables you to use your computer on more than one network with the click of a button. All changes are made instantly, and no reboot is required. The program lets you automatically select the correct drive mappings, printer settings, IP addressing. It's the ultimate tool for laptop users on different networks. This version adds support for manu...

Spoofing Your IP Address During A Port Scan – Part 1

Spoofing Your IP Address During A Port Scan – Part 1 I love debunking myths, one of my favorites is “a port scanner must reveal his true source IP address”. In this series I’ll show you how to perform a port scan while hiding your source IP address from the host being scanned. I’ll also tell you how you can detect the technique when it is used against you. Nmap’s decoy mode An alternative to the technique I will describe is nmap’s decoy mode. With decoy mode you identify a number of bogus source IP addresses. From the target host, it looks like all of the bogus IP addresses, as well as the true source IP address, are all performing a port scan at the same time. The concept is the administrator under attack will have no way of knowing which IP address is in fact the true IP performing the scan. This technique really does not mask the true source, as the source IP address is one of the IPs performing the scan. If you know what to look for, you can easily figure out which source IP is ac...

Spoofing Your IP Address During A Port Scan – Part 2

Spoofing Your IP Address During A Port Scan – Part 2 In my last post I discussed an idle scan and how it can permit an attacker to mask their IP address during a port scan. In this installment we’ll look at some traces, as well as discuss how to identify when an idle scan has been used against your network. Monitoring the IP ID increment Let’s start by looking at the packets that were monitoring the IP ID field on the Windows system. Here is what our probe packet looked like: 07:22:15.367140 IP (tos 0×0, ttl 64, id 63897, offset 0, flags [none], proto TCP (6), length 40) 192.168.100.1.2203 > 192.168.100.2.0: ., cksum 0xeca2 (correct), win 512 A few of these fields are kind of interesting. The TTL value is set to “64”, which suggests a Linux or UNIX system. Since we are raw writing the packet directly to the wire this value is actually controlled by hping. 64 just happen to be the program default, but we could change the value to anything we wish with the “-t” switch. The target addr...