Networking Forums

Networking Forums > Computer Networking > Linux Networking > Basic understanding of Subnetting

Reply
Thread Tools Display Modes

Basic understanding of Subnetting

 
 
Cameron Kerr
Guest
Posts: n/a

 
      05-23-2004, 01:17 AM
Webmaster <(E-Mail Removed)> wrote:

> -Does this sound correct?


Almost, but what you call a "subnet", is really a "subnet mask".
Kernel IP routing table
Destination Gateway Genmask Flags Iface
202.89.56.1 0.0.0.0 255.255.255.255 UH ppp0
192.168.2.0 0.0.0.0 255.255.255.0 U eth1
10.18.0.0 0.0.0.0 255.255.0.0 U eth0
0.0.0.0 202.89.56.1 0.0.0.0 UG ppp0

Assume a packet comes into the router destined for 10.18.1.2. As a
simplified explanation (ignoring route cache), the packet will first be
AND'd with the first mask in the table (255.255.255.255). The result
is 10.18.1.2. This doesn't match the first destination 202.89.56.1,
so the route lookup code will go onto the next route entry.

Repeat using the next entry in the table.

10.18.1.2 && 255.255.255.0 = 10.18.1.0
192.168.2.0 != 10.18.1.0 so next route table entry.

10.18.1.2 && 255.255.0.0 = 10.18.0.0
10.18.0.0 == 10.18.0.0 (a match!)

The route entry that matched is

Destination Gateway Genmask Flags Iface
10.18.0.0 0.0.0.0 255.255.0.0 U eth0

There is no gateway associated with this route (no G in Flags), so it
get's sent out eth0 (the Iface)


Given the same routing table, a different packet destined for
123.123.12.3 would match the following route entry (which is the default
route, as anything ANDed with 0 is 0).

Destination Gateway Genmask Flags Iface
0.0.0.0 202.89.56.1 0.0.0.0 UG ppp0

Now, there is a G in the flags, so the packet goes out ppp0. The
destination address is unchanged. ppp0 is a Point-to-point link, so we
just need to throw it through the pipe, and it'll come out the other
end.

If the default route were to an ethernet, the IP address (as always)
will still be unchanged, but the layer 2 MAC address (destination
ethernet address) will be the MAC address of the gateway's interface on
that ethernet.

--
Cameron Kerr
(E-Mail Removed) : http://nzgeeks.org/cameron/
Empowered by Perl!
 
Reply With Quote
 
 
 
 
Webmaster
Guest
Posts: n/a

 
      05-23-2004, 02:20 AM

Hello,

Here is what I think I know:
Subnets exist for at least this reason:
-If the network portion of a packet
matches the part that is masked
by a subnet, the kernel
then consults its arp table.

-If the network portion does not
match, it forwards to the gateway.

i.e.:
A packet bound for 192.168.12.1 first arrives
at 192.168.12.4

192.168.12.4 has a subnet of 255.255.255.0

192.168.12.4 recognizes that the subnet mask
matches the packet exactly, therefore it consults
its arp table and sends the happy packet on
through the woods to the MAC address in its arp table.

-Does this sound correct?

Thanks
Josh Beck


 
Reply With Quote
 
Raqueeb Hassan
Guest
Posts: n/a

 
      05-23-2004, 06:54 AM
you are right.

see this example ...

your system 192.168.10.1 11000000 10101000 00001010 00000001
local server 192.168.10.10 11000000 10101000 00001010 00001010
Any network 207.68.137.53 11001111 01000100 10001001 00110101
Subnet-mask 255.255.255.0 11111111 11111111 11111111 00000000

TCP/IP compare now the part of the addresses, defined by the '1's in
the subnet-mask ( or simple: the part of the IP-addresses, where the
subnet-mask is 255 ):
xxx indicates, that this part of an IP-address does not matter anymore
:

System: IP/subnet-mask Binary
your system 192.168.10.xxx 11000000 10101000 00001010 xxxxxxxx
local server 192.168.10.xxx 11000000 10101000 00001010 xxxxxxxx
any network 207.68.137.xxx 11001111 01000100 10001001 xxxxxxxx
Subnet-mask 255.255.255.0 11111111 11111111 11111111 00000000

you might consult http://www.wown.com/j_helmig/tcpip.htm for more of
it!

hth

raqueeb hassan
congo
 
Reply With Quote
 
James Knott
Guest
Posts: n/a

 
      05-23-2004, 01:41 PM
Webmaster wrote:

>
> Hello,
>
> Here is what I think I know:
> Subnets exist for at least this reason:
> -If the network portion of a packet
> matches the part that is masked
> by a subnet, the kernel
> then consults its arp table.
>
> -If the network portion does not
> match, it forwards to the gateway.
>
> i.e.:
> A packet bound for 192.168.12.1 first arrives
> at 192.168.12.4
>
> 192.168.12.4 has a subnet of 255.255.255.0
>
> 192.168.12.4 recognizes that the subnet mask
> matches the packet exactly, therefore it consults
> its arp table and sends the happy packet on
> through the woods to the MAC address in its arp table.
>
> -Does this sound correct?
>


A better way to describe it, would be to say that the subnet mask is used to
determine if the destination is on the local network. It works by
performing a logical AND of the destination address with the mask, to see
if it matches the local network.


--

Fundamentalism is fundamentally wrong.

To reply to this message, replace everything to the left of "@" with
james.knott.
 
Reply With Quote
 
Webmaster
Guest
Posts: n/a

 
      05-23-2004, 04:34 PM
On Sun, 23 May 2004, James Knott wrote:

> Webmaster wrote:
>
> >
> > Hello,
> >
> > Here is what I think I know:
> > Subnets exist for at least this reason:
> > -If the network portion of a packet
> > matches the part that is masked
> > by a subnet, the kernel
> > then consults its arp table.
> >
> > -If the network portion does not
> > match, it forwards to the gateway.
> >
> > i.e.:
> > A packet bound for 192.168.12.1 first arrives
> > at 192.168.12.4
> >
> > 192.168.12.4 has a subnet of 255.255.255.0
> >
> > 192.168.12.4 recognizes that the subnet mask
> > matches the packet exactly, therefore it consults
> > its arp table and sends the happy packet on
> > through the woods to the MAC address in its arp table.
> >
> > -Does this sound correct?
> >

>
> A better way to describe it, would be to say that the subnet mask is used to
> determine if the destination is on the local network. It works by
> performing a logical AND of the destination address with the mask, to see
> if it matches the local network.
>
>
>

Thank you all. Very Helpful


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help understanding this behaviour SeriousSam Windows Networking 6 12-10-2007 10:02 PM
syn flood understanding Andy Linux Networking 0 11-08-2007 05:07 PM
Understanding TCPDUMP Rav Linux Networking 5 11-02-2006 11:47 PM
DNS documents for thorough understanding. in1478c Linux Networking 2 01-05-2006 11:00 AM
A lack of basic understanding.. Setting up network. Linux & Win XP Trevor Linux Networking 0 08-15-2005 04:29 PM



1 2 3 4 5 6 7 8 9 10 11