Re: Netmasks for dummies

From: Centurion (spam.this_at_nowhere.tld)
Date: 02/22/05


Date: Tue, 22 Feb 2005 20:18:01 +1100

StupidScript wrote:

> Just so I understand the system, or at least get a crib sheet for it,
> please let me know if the following is incorrect:
>
> ============= Scenario 1 - 8 addresses: =============
> My ISP has assigned me IPs "198.113.64.1" through "198.113.64.8"
>
> The netmask which accomodates this could be written as either:
> "255.255.255.248" or as "/29"

198.113.64.1 and 198.113.64.8 are NOT valid network boundaries for a /29
subnet. 198.113.64.0-198.113.64.7 is a valid IP block for a /29 subnet.

/29 or 255.255.255.248 defines the subnet mask which assigns a certain
number of bits to the network and the remainder to the host.

/29 has 29 bits allocated to the network and 3 bits allocated to the hosts.
Therefore 2^3=8 which is the number of valid addresses on a /29 subnet. Of
that 8, 1 is a network address and 1 is a broadcast address.

In your case (example):
198.113.64.0 = network
198.113.64.1-198.113.64.6 = hosts/machines etc.
198.113.64.7 = broadcast

192.113.64.8 = the next /29 network's address.... and so on.

> In my iptables, I could DROP all packets coming from any machine on my
> subnet ONLY by identifying the incoming IP range as:
> "198.113.64.1/255.255.255.248" or as "198.113.64.1/29"

replace .1 with .0 and you've got it.

> ============= Scenario 2 - 16 addresses: =============
> My ISP has assigned me IPs "198.113.64.1" through "198.113.64.16"
>
> The netmask which accomodates this could be written as either:
> "255.255.255.240" or as "/28"

Gah - see above. 198...0 - 198...15 is the address range. .0 is the network
address, .15 is the broadcast, .1-.14 are valid host addresses.

> In my iptables, I could DROP all packets coming from any machine on my
> subnet ONLY by identifying the incoming IP range as:
> "198.113.64.1/255.255.255.240" or as "198.113.64.1/28"

replace .1 with .0

> ============= Last Scenario - 128 addresses: =============
> My ISP has assigned me IPs "198.113.64.1" through "198.113.64.128"

Godammit :P (See above).

> The netmask which accomodates this could be written as either:
> "255.255.255.128" or as "/25"
>
> In my iptables, I could DROP all packets coming from any machine on my
> subnet ONLY by identifying the incoming IP range as:
> "198.113.64.1/255.255.255.128" or as "198.113.64.1/25"

s/\.1/\.0/
  
> Am I off base? I appreciate any responses.

On EVERY IP network, 2 addresses are 'wasted' because every IP networks
requires a network address and a broadcast address. Therefore the smallest
subnet possible is a /30 (255.255.255.252) which leaves 30 allocated to the
network and 2 bits to the address giving 4 addresses in total; 1 network, 2
hosts and 1 broadcast. I use these for connecting routers together on uor
internal network. That way the only valid addresses are each end of the
link ;)

Get hold of "ipsc" - IP Subnet Calculator. It's a command line utility
that's been compiled for nearly every OS known to man (and woman) AFAIK.

James

-- 
Your lucky number has been disconnected.


Relevant Pages

  • problems with logical && (and) statement
    ... I have been working on a writing a script to compare host information from ... am trying to check for is if the host is on the same network in both lists, ... and then I am checking to see if it is the same subnet in both lists. ... print "in the dhcp lease file I found $wkrst with ip addr ...
    (perl.beginners)
  • Re: how to get a networks IPs?
    ... >sniff a network without knowing with what IP to configure ... host routes, and have not one single pre-existing host on a ... the right subnet for the IP range that could be used... ... ping will be answered by every interface on the LAN that can ...
    (comp.os.linux.networking)
  • Re: single host netmask (255.255.255.255)
    ... The routes from three interfaces, propagate via OSPF to the rest of network.... ... One way is to remember IP addresses assigned to each interfaces, but more smart solution is to assign to this machine one EXTERNAL LOOPBACK address (single IP with mask 255.255.255.255, in other words SINGLE HOST assigned to Microsoft loopback adapter), and propagate this address ... The address 255.255.255.255 denotes a broadcast on a local hardware network, ...
    (microsoft.public.win2000.networking)
  • Re: IP Address Config
    ... The subnet mask is: 255.255.255.248 ... So what should my broadcast and network addresses be? ... > chunk being the network, and the top address in each chunk being the ...
    (Fedora)
  • Re: TCP/IP question,PLEASE!
    ... mask is and how to apply it to IP address. ... a subnet is. ... For hosts to be in the same subnet, they must have the same network address. ... A host address's components: ...
    (microsoft.public.windowsxp.general)