Networking For Hacker’s | Part-2

ai generated, computers, technology-8242237.jpg

Introduction

Welcome back to our “Networking For Hackers” series! In this second part, we’re breaking down some important networking ideas in a straightforward way. Your IP address is like your digital home address, MAC addresses are like serial numbers for your devices, and Network Address Translation (NAT) is like a go-between for your home network and the internet.

If you’re ready to learn more about how information moves around networks and pick up some useful knowledge for navigating the online world, then stick with us!

What is an IP (Internet Protocol) Address ?

An IP address is like your device’s internet name tag. It’s a special set of numbers that tells other devices where to find you online. Your device’s IP address is like its own digital mailbox. When you’re surfing the web, this address helps other computers know where to send information. So, similar to how you have a mailbox for receiving letters, your device has an IP address for getting data from websites. Basically, it’s all about how devices talk and exchange things on the internet.

There are two main types of IP addresses: IPv4 (Internet Protocol version 4) and IPv6 (Internet Protocol version 6).

How to find your Local IP Address

You always going to need your IP address while testing anything.

  • For Linux or MacOS users, access your terminal and type “ifconfig”.
  • For Windows users, open either the command prompt or Power Shell, and enter “ipconfig /all”.

ifconfig command showing ipv4 ipv6 & mac address. computer networking

Here in above image,
inet -> This displays your local IP address, typically using the IPv4 protocol, represented by a 32-bit decimal number
inet6 -> Represents the newer version of IP (IPv6), utilizing a 128-bit hexadecimal value.
ether -> MAC address: a distinctive identifier assigned to your network interface controller (NIC)

The Mathematics of IPv4 in Networking

image showing ipv4 address format

IPv4 addresses consist of 32 bits, organized into 4 octets of 8 bits each, with values ranging from 0 to 255 in each octet.

Ipv4 address on above image in decimal form is 192.168.101.144
Binary form of this address is 11000000.10101000.01100101.10010000

An octet comprises 8 bits, with each bit representing either a 0 or a 1.

0 or 10 or 10 or 10 or 10 or 10 or 10 or 10 or 1
8th bit7th bit6th bit5th bit4th bit3rd bit2nd bit1st bit
128 (2^7)64 (2^6)32 (2^5)16 (2^4)8 (2^3)4 (2^2)2 (2^1)1 (2^0)

Converting binary octets to decimal follows a pattern:

starting from the right, the least significant bit holds a value of 2^0. Moving left, each subsequent bit doubles in value until reaching the most significant bit, which holds a value of 2^7. When all bits are 1, the decimal equivalent is 255.

That means:

All 8 bits are 111111111
Decimal equivalent of each 1 bit1286432168421

Sum of all decimal equivalent bits are : 128+64+32+16+8+4+2+1 = 255

Octet Conversion Example:

Let's suppose we have IP address: 192.168.94.5
Let's  calculate the first octet (192.), from binary format to decimal:
Decimal Equivalent of each bit1286432168421
8 bit Binary format of first octet (192)11000000

Only the 8th and 7th bits are set to 1, while the remaining bits (6th to 1st) are off.

Thus, the decimal value is the sum of these positions: 128 + 64 = 192

Private & Public IP Address in Networking

Think of a public IP address like a phone number that everyone can use to call a device on the internet. It helps devices talk to each other across the web.

Meanwhile, a private IP address is more like an extension number within a building – it’s just for communicating with other devices within your own private network, like your home Wi-Fi or office network.

IP addresses within the following subnets are considered private:

Network ClassNetwork NumberNetwork MaskNo. of NetworksNo. of Hosts per Network
Class A10.0.0.0 to 10.255.255.255255.0.0.012616,646,144
Class B172.16.0.0 to 172.31.0.0255.255.0.016,38365.024
Class C192.168.0.0 to 192.168.255.255255.255.255.02,097,151254
LOOPBACK
(localhost)
127.0.0.0 to 127.0.0.7255.255.255.0

IPv4 vs IPv6

IPv4IPv6
Uses 32-bit addressesUses 128-bit addresses
Address space limited (4.3 billion)Address space vast (340 undecillion)
IPv4 addresses are hierarchicalIPv6 addresses are flat
Configured manually or via DHCPSupports both manual and DHCPv6
Address format: dotted-decimal notationAddress format: hexadecimal notation
Example: 192.168.1.1Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Why Switch to IPv6 if We Already Have IPv4 in Networking ?

IPv6 comes into play because IPv4, our old system, is getting cramped. It’s like having too few seats at a party when more and more guests show up. With IPv6, it’s as if we’re adding more tables and chairs to accommodate everyone comfortably, ensuring nobody gets left standing.

In simple terms, IPv6 gives us enough room to connect all our devices without worrying about running out of space.

Media Access Control (MAC)

networking mac diagram showing OUI and UAA

Sometimes, two devices on a network can end up with the same IP address, causing confusion. To fix this, we use MAC addresses. These are unique codes, kind of like fingerprints, given to each device by the manufacturer. They’re permanent and help ensure that data goes to the right place on the network, regardless of IP addresses. So, while IP addresses can be the same, MAC addresses make sure each device gets its messages.

Network Address Translation (NAT)

In NAT, each device within the local network typically has its own private IP address, but these private addresses are not directly accessible from the internet. Instead, NAT assigns a single public IP address to represent the entire local network when communicating with external networks like the internet. So, while each device has its own private address within the local network, externally they are represented by a single public IP address assigned by NAT.

There are three main types of NAT:

  1. Static NAT: In Static NAT, a one-to-one mapping is established between a private IP address and a public IP address. This mapping remains constant and does not change over time.
  2. Dynamic NAT: Dynamic NAT assigns a public IP address from a pool of available addresses to a device with a private IP address when it requests access to the internet. The mapping is temporary and changes dynamically based on demand.
  3. PAT (Port Address Translation): It maps multiple private IP addresses to a single public IP address by using different port numbers to distinguish between individual connections. This allows multiple devices within a local network to share a single public IP address.

Conclusion

In this blog, we covered IP addresses, MAC addresses, and NAT in detail, learning why they’re important in networking. We also discussed the significance of IPv6 and MAC addresses. Next up in “Networking For Hackers | Part-3” we’ll dive into subnetting, a topic essential for hacking.

Keep an eye out for more insights to level up your hacking expertise!

Subscribe to Our FREE Daily Newsletter For Hacker’s & Tech. Students
New here? Read “Networking For Hacker’s | Part-1” & Follow Us on Instagram, LinkedIn, Facebook

Leave a Comment

Your email address will not be published. Required fields are marked *