Networking Forums

Networking Forums > Computer Networking > Linux Networking > Network including host?

Reply
Thread Tools Display Modes

Network including host?

 
 
Humboldt
Guest
Posts: n/a

 
      10-24-2003, 08:27 AM
Hi,

I'm trying to write an application (function) in php, which returns
true/false if a given network includes a single host. The network
adress is given as 243.8.23.11/24 (or whatever) and the host
243.8.23.22 (without netmask). If I would have a netmask for the host,
it would be easy to find out, because ip of host (binary) AND netmask
(binary) give out the belonging network.
But in this case, I suppose I have to make a loop an try out all
possible netmasks from /32 to /1 to find out which are the possible
networks the host can be belonging to.
Does anyone out there have an idea how to realize that easily? Or is
there some code / informative text I could find useful somewhere in
the net?

Thanks for any help

SvT
 
Reply With Quote
 
 
 
 
Frank Sweetser
Guest
Posts: n/a

 
      10-24-2003, 02:26 PM
Humboldt <(E-Mail Removed)> wrote:
> Hi,
>
> I'm trying to write an application (function) in php, which returns
> true/false if a given network includes a single host. The network
> adress is given as 243.8.23.11/24 (or whatever) and the host
> 243.8.23.22 (without netmask). If I would have a netmask for the host,
> it would be easy to find out, because ip of host (binary) AND netmask
> (binary) give out the belonging network.


Huh? The netmask is an attribute of the IP configuration of the subnet. All
machines on that subnet must have the same netmask, or else they're
misconfigured and probably won't work quite right. You already say that you
have the mask, so you can just use that.

--
Frank Sweetser fs at wpi.edu
WPI Network Engineer
 
Reply With Quote
 
Safran von Twesla
Guest
Posts: n/a

 
      10-25-2003, 10:00 AM
On Fri, 24 Oct 2003 14:26:12 +0000 (UTC), Frank Sweetser
<(E-Mail Removed)> wrote:

>Humboldt <(E-Mail Removed)> wrote:
>> Hi,
>>
>> I'm trying to write an application (function) in php, which returns
>> true/false if a given network includes a single host. The network
>> adress is given as 243.8.23.11/24 (or whatever) and the host
>> 243.8.23.22 (without netmask). If I would have a netmask for the host,
>> it would be easy to find out, because ip of host (binary) AND netmask
>> (binary) give out the belonging network.

>
>Huh? The netmask is an attribute of the IP configuration of the subnet. All
>machines on that subnet must have the same netmask, or else they're
>misconfigured and probably won't work quite right. You already say that you
>have the mask, so you can just use that.


It's not my network. I'm working on a php-programm, a grafical
interface for a firewallsystem on which a lot of other networks and
hosts are attached directly or not.
So, when configuring, the user has to enter some values, as for
example the adress of a network. There is also a form for individual
hosts, which have different rules. And to find out, when entering a
new network, I want to check of this network does include or not the
already entered single host. For example.
That I can calculate all that is clear, but a user should not do that,
so I'm looking for a formula that calculates it for me. Ok?
I hope you now understand what I'm looking for ;-)

Thanks

SvT

 
Reply With Quote
 
Frank Sweetser
Guest
Posts: n/a

 
      10-25-2003, 01:22 PM
Safran von Twesla <(E-Mail Removed)> wrote:
> It's not my network. I'm working on a php-programm, a grafical
> interface for a firewallsystem on which a lot of other networks and
> hosts are attached directly or not.
> So, when configuring, the user has to enter some values, as for
> example the adress of a network. There is also a form for individual
> hosts, which have different rules. And to find out, when entering a

^^^^^^^^^^^^^^^^^^^^^^^^^^

No, they don't.

There is no host netmask versus network netmask. There is only the netmask
of a given subnet.

> new network, I want to check of this network does include or not the
> already entered single host. For example.


So the user gives you an ip and netmask. From this, you can calculate the
network.

network base = ip & netmask

They then give you another ip. You can easily calculate if this is in the
first one.

if ( (ip & netmask) == network base )
ip is in network
else
ip is not in network

If, with the ip, they give you a different netmask - then it's a *different*
network. It may overlap with the previous one, but a subnet is defined by the
base address and the netmask, so if the user gives you a different one then
it's a different one.

You might want to pick up a few books on IP fundamentals or read some of the
RFCs - they'll give you the full story.

--
Frank Sweetser fs at wpi.edu
WPI Network Engineer
 
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
Host-to-host connection in wireless adhoc network? Tim Boneko Linux Networking 0 08-17-2005 05:28 PM
Free BT Yahoo email (including POP3 access) for BT Broadband customers Sunil Sood Broadband 0 04-17-2005 10:32 AM
A comparison among VSS Remote Access Tools including SourceOffSite, SourceAnyWhere and VSS Remoting bettervssremoting Windows Networking 0 02-28-2005 09:27 AM
A comparison among VSS Remote Access Tools including SourceOffSite, SourceAnyWhere and VSS Remoting bettervssremoting Windows Networking 0 02-28-2005 09:27 AM
Help with Linux iptables details (including some terms) ctt Linux Networking 2 06-12-2004 05:26 PM



1 2 3 4 5 6 7 8 9 10 11