IPv4 and IPv6 Subnet Mask Cheat Sheet

Listen to this Post

Featured Image
Subnetting is a fundamental skill for network administrators and cybersecurity professionals. Understanding IPv4 and IPv6 subnet masks helps in efficient IP address allocation, network segmentation, and security enforcement. Below is a detailed cheat sheet along with practical commands and examples.

IPv4 Subnet Mask Cheat Sheet

| CIDR | Subnet Mask | Number of Hosts |

||-|–|

| /32 | 255.255.255.255 | 1 |

| /24 | 255.255.255.0 | 254 |

| /16 | 255.255.0.0 | 65,534 |

| /8 | 255.0.0.0 | 16,777,214 |

IPv6 Subnet Mask Cheat Sheet

| Prefix Length | Example IPv6 Subnet | Hosts Available |

|||–|

| /64 | 2001:db8::/64 | 18,446,744,073,709,551,616 |

| /56 | 2001:db8::/56 | 4,722,366,482,869,645,000 |

| /48 | 2001:db8::/48 | 1,208,925,819,614,629,000 |

You Should Know:

1. Calculating Subnets in Linux

Use `ipcalc` to determine subnet ranges:

ipcalc 192.168.1.0/24 

Output:

Address: 192.168.1.0 
Netmask: 255.255.255.0 
Network: 192.168.1.0/24 
HostMin: 192.168.1.1 
HostMax: 192.168.1.254 

2. Configuring IPv6 on Linux

Assign an IPv6 address:

ip -6 addr add 2001:db8::1/64 dev eth0 

Verify:

ip -6 addr show eth0 

3. Windows Subnet Commands

Check subnet mask in Windows:

ipconfig /all 

Add a static route:

route add 192.168.2.0 mask 255.255.255.0 192.168.1.1 

4. Subnetting for Security

Restrict SSH access to a subnet:

sudo ufw allow from 192.168.1.0/24 to any port 22 

5. IPv6 Firewall Rule (Linux)

Allow ICMPv6 (essential for IPv6):

sudo ip6tables -A INPUT -p icmpv6 -j ACCEPT 

6. Network Scanning with Nmap

Scan a subnet for live hosts:

nmap -sn 192.168.1.0/24 

7. Convert CIDR to Subnet Mask (Python)

import ipaddress 
net = ipaddress.IPv4Network("192.168.1.0/24") 
print("Subnet Mask:", net.netmask) 

What Undercode Say

Subnetting is crucial for optimizing network performance and security. By mastering IPv4 and IPv6 subnet masks, you can:
– Reduce broadcast traffic
– Implement Zero Trust segmentation
– Detect unauthorized IP ranges
– Prevent lateral movement in cyber attacks

Advanced Commands:

  • List all IPv6 neighbors:
    ip -6 neighbor show 
    
  • Check IPv6 routing table:
    ip -6 route show 
    
  • Test IPv6 connectivity:
    ping6 2001:db8::1 
    

Expected Output:

Address: 192.168.1.0 
Netmask: 255.255.255.0 
Network: 192.168.1.0/24 
HostMin: 192.168.1.1 
HostMax: 192.168.1.254 

References:

Reported By: Https: – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram