From owner-freebsd-questions@FreeBSD.ORG Tue Apr 29 10:56:23 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6C3437B401 for ; Tue, 29 Apr 2003 10:56:23 -0700 (PDT) Received: from pa-plum1b-166.pit.adelphia.net (pa-plum1a-215.pit.adelphia.net [24.53.170.215]) by mx1.FreeBSD.org (Postfix) with ESMTP id F39A543FAF for ; Tue, 29 Apr 2003 10:56:22 -0700 (PDT) (envelope-from wmoran@potentialtech.com) Received: from potentialtech.com (working [172.16.0.95]) h3THuK0n004654; Tue, 29 Apr 2003 13:56:21 -0400 (EDT) (envelope-from wmoran@potentialtech.com) Message-ID: <3EAEBCC4.4070606@potentialtech.com> Date: Tue, 29 Apr 2003 13:56:20 -0400 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3) Gecko/20030429 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Steve Warwick References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-questions@FreeBSD.ORG Subject: Re: Netmasks: the truth is out there? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Apr 2003 17:56:24 -0000 Steve Warwick wrote: > Hi All, > > I know someone out there knows the truth about netmasks. All the > documentation I can find on the net talks about "masking off" part of the IP > address and how you can tell network from subnet and host ids. > > However, I have knowledgeable friend who is telling me that the netmask is > also dependant on how the hosting company has set up their routing tables > and incorrect netmasking on my part can reduce or halt my connection. > > So the question is, who is right? Is it as simple as just masking off the > first three octets or does the netmask interact with the router? > > Please point me to an authoritative source or if you have the time, a brief > description of if or how the netmask has to match the router, as I am not > sure what questions to ask my hosting company. I don't know of any good primer for IP routing/netmasks, so I'll explain it briefly. First, you need to know how to do a binary "and" operation. (I'll use & to represent and to save typing) Basically, 1 & 1 = 1, 1 & 0 = 0, 0 & 0 = 0 On a larger scale: 255 & 240 = 240, 128 & 64 = 0, 15 & 3 = 3, 3 & 6 = 2 If you don't understand how those work out, you will not understand the rest. Find an explanation of binary operations such as "and" and study it until those examples make sense to you. Most of the people I know who think they understand IP/netmasks and yet screw it up all the time don't understand a basic binary and operation. Now, once you've got that, there's a very simple equation: IP & netmask = network number It's that simple, but the implications are considerable: 1) When you configure a network card, you provide ip, netmask ... the system can calculate the network number, and from network number/ netmask, it can determine whether or not any given IP is on that network or not. This is how routing works. 2) Routers have many interfaces and netmasks. If they're configured wrong, packets go the wrong way and network traffic works poorly (if at all) 3) On a workstation, routing is much simpler. You have two routes of importance: The route to the local network and the default route Using the network number/netmask equation, each packet is checked to see if it's on the local network: if not, it's forwarded to the default gateway. If your netmask is wrong on a workstation, it's possible (depending on how wrong it is) for networking not to work at all, or only fail occasionally. 4) On a gateway, it's still pretty simple: You have two routes based on IP/netmask. The system checks each packet to see if it belongs on one of those, if so, that's the network card the packet is sent out. Othewise, it's forwarded to that gateway's default gateway. Bungled netmasks on a gateway can cause problems from complete failure to a few sites that are inaccessable. Use "netstat -rn" to see your local routing table. This should help some. netstat uses a slightly different notation for netmasks, it uses the /## notation (for example 172.16/16) This means: "the first 16 bits are ones and the rest are zeros". The logic, math, etc is the same as if you said 255.255.0.0, just the notation is shorter. (takes up less space on the screen) Hope this helps. -- Bill Moran Potential Technologies http://www.potentialtech.com