Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

Basic understanding of Subnetting

Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2004, 02:17 AM
Default Re: Basic understanding of Subnetting



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!


Cameron Kerr
Reply With Quote
  #2  
Old 05-23-2004, 03:20 AM
Webmaster
Guest
 
Posts: n/a
Default Basic understanding of Subnetting


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
  #3  
Old 05-23-2004, 07:54 AM
Raqueeb Hassan
Guest
 
Posts: n/a
Default Re: Basic understanding of Subnetting

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
  #4  
Old 05-23-2004, 02:41 PM
James Knott
Guest
 
Posts: n/a
Default Re: Basic understanding of Subnetting

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
  #5  
Old 05-23-2004, 05:34 PM
Webmaster
Guest
 
Posts: n/a
Default Re: Basic understanding of Subnetting

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

Tags
basic, subnetting, understanding

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
Forum Jump


All times are GMT. The time now is 04:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.