Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Obtain subnet mask of host

Thread Tools
 
Search this Thread
 
Old 11 January 2011, 12:04 PM
  #1  
mike1210
Scooby Regular
Thread Starter
 
mike1210's Avatar
 
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes on 0 Posts
Default Obtain subnet mask of host

Hello all,
I have an issue finding a hosts subnet mask.

I have a website that people access to register for a service on their host computers. There are DOS commands which run inside a PHP script to obtain their IP and MAC address however ideally we also need to obtain subnet mask of the machine.

Does anyone know of a way to do this,ideally I need the webpage to obtain the info without using remote IP tools

Mike
Old 11 January 2011, 12:27 PM
  #2  
Dedrater
Scooby Regular
 
Dedrater's Avatar
 
Join Date: May 2008
Posts: 3,957
Likes: 0
Received 0 Likes on 0 Posts
Default

I don't think you will be able to obtain that using PHP, they are not sent in TCP/IP packets and are part of an internal network, which shares the same external IP.
Old 11 January 2011, 07:18 PM
  #3  
hodgy0_2
Scooby Regular
 
hodgy0_2's Avatar
 
Join Date: Jul 2008
Location: K
Posts: 15,633
Received 21 Likes on 18 Posts
Default

impossible -- the subnet mask is only of value when on the same LAN segment as the host i.e. to determin whether an IP address belongs on the LAN segment.

over the wan it will just be 255.255.255.255 (or assumed to be -- i.e. the host)

Last edited by hodgy0_2; 11 January 2011 at 07:22 PM.
Old 11 January 2011, 11:29 PM
  #4  
mike1210
Scooby Regular
Thread Starter
 
mike1210's Avatar
 
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes on 0 Posts
Default

Thanks Both

Hodgy - The machines that access the website are on the same Autonomous System so to speak with public IP's. However, they will be on seperate VLAN's to the server itself, so I'm guessing this is still a no no.

Mike
Old 12 January 2011, 11:14 AM
  #5  
hodgy0_2
Scooby Regular
 
hodgy0_2's Avatar
 
Join Date: Jul 2008
Location: K
Posts: 15,633
Received 21 Likes on 18 Posts
Default

hi

does your application see the remote host’s real ip address or a natted address.

the MAC address that you get, presumably this is the MAC address of the DG interface of your Host/Application LAN segment

I would have thought the actual MAC address of the host can only be retrieved by an ARP request from a device (Router Interface) on the hosts LAN segment - do you do this?
Old 12 January 2011, 12:23 PM
  #6  
LeeP
Scooby Regular
iTrader: (7)
 
LeeP's Avatar
 
Join Date: Nov 2009
Location: Leeds
Posts: 579
Likes: 0
Received 0 Likes on 0 Posts
Default

Yeah - I guess if you're in the same AS and you're *not* having to NAT then the subnet mask would be useful. However, is there asymmetric routing going on, one with a smaller mask to another?

If it's just a client, can the script in DOS not just grab the full ipconfig / all data and strip out the data it needs?

I guess if it goes through a gateway or part of a summarised network, the actual mask itself of the host wouldn't be any use?
Old 12 January 2011, 11:42 PM
  #7  
mike1210
Scooby Regular
Thread Starter
 
mike1210's Avatar
 
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by hodgy0_2
hi

does your application see the remote host’s real ip address or a natted address.

the MAC address that you get, presumably this is the MAC address of the DG interface of your Host/Application LAN segment

I would have thought the actual MAC address of the host can only be retrieved by an ARP request from a device (Router Interface) on the hosts LAN segment - do you do this?
* Real IP, all the staff machines on our network use public IP addresses.

* to get the MAC we fire the nbtstat command out to the machine, this returns the mac of the host

* Pretty sure it's just the nbtstat command to get the Mac

Trending Topics

Old 12 January 2011, 11:54 PM
  #8  
mike1210
Scooby Regular
Thread Starter
 
mike1210's Avatar
 
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by LeeP
Yeah - I guess if you're in the same AS and you're *not* having to NAT then the subnet mask would be useful. However, is there asymmetric routing going on, one with a smaller mask to another?

If it's just a client, can the script in DOS not just grab the full ipconfig / all data and strip out the data it needs?

I guess if it goes through a gateway or part of a summarised network, the actual mask itself of the host wouldn't be any use?
* sometimes yes, the network is mainly split by /24 VLANs however we do have some /27's for example which causes the problem as we cannot assume the subnet mask is 255.255.255.0

* Yes I'm guessing there must be a way to search for *255.255* and take the data after it

* We need the mask for the machine as we send out a magic packet to it to wake it up.

In a nutshell the service is so staff members can wake up their machines from home as we forcefully power them off every night to save power.

They log in to a website from their staff machine and register for the "wake up service"

This logs their username, mac and IP however it assumes the network is always a /24 network, so users who are on a /27 who try to wake up their machines can't.

The users can then log into the website from home and type their username and hit "wake up" which poweres their machine on.
Old 13 January 2011, 08:10 AM
  #9  
hodgy0_2
Scooby Regular
 
hodgy0_2's Avatar
 
Join Date: Jul 2008
Location: K
Posts: 15,633
Received 21 Likes on 18 Posts
Default

ah ok

from the above I think it might be possible

how do the client get their IP's - DHCP?

do you use a DHCP relay /IPhelper address
Old 13 January 2011, 08:54 AM
  #10  
mike1210
Scooby Regular
Thread Starter
 
mike1210's Avatar
 
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes on 0 Posts
Default

clients use Static IP's via DHCP

not sure if a helper is used ..... I know networks are reluctant to give those out.

I think the routers are tweaked to allow the DHCP ACK across VLAN's as its on a seperate subnet to other machines.

Thanks all
Old 13 January 2011, 09:51 AM
  #11  
hodgy0_2
Scooby Regular
 
hodgy0_2's Avatar
 
Join Date: Jul 2008
Location: K
Posts: 15,633
Received 21 Likes on 18 Posts
Default

do you know the IP ranges used in the network (with subnet addressing)

if so could you not create you own "DHCP" type database, then when you know the IP address of the connecting client you could do a lookup against your database to find the correct subnet mask
Old 13 January 2011, 07:51 PM
  #12  
HHxx
Scooby Regular
 
HHxx's Avatar
 
Join Date: Nov 2001
Posts: 2,576
Likes: 0
Received 0 Likes on 0 Posts
Default

Why not just interrogate the DHCP database directly? It contains all the information you need?
Old 13 January 2011, 08:05 PM
  #13  
hodgy0_2
Scooby Regular
 
hodgy0_2's Avatar
 
Join Date: Jul 2008
Location: K
Posts: 15,633
Received 21 Likes on 18 Posts
Default

yep - that makes sense (i was sort assuming the "notworking" team would not let you lookup the DHCP database)
Old 13 January 2011, 08:31 PM
  #14  
HHxx
Scooby Regular
 
HHxx's Avatar
 
Join Date: Nov 2001
Posts: 2,576
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by hodgy0_2
yep - that makes sense (i was sort assuming the "notworking" team would not let you lookup the DHCP database)
I suppose that could be a problem. Didn't think of that as all areas in Europe for my company fall under my team.

Get them to export the data out regularly or set it up to replicate to another DB?

Anyway, how are you getting the magic packet routed across your subnets?
Old 13 January 2011, 08:42 PM
  #15  
hodgy0_2
Scooby Regular
 
hodgy0_2's Avatar
 
Join Date: Jul 2008
Location: K
Posts: 15,633
Received 21 Likes on 18 Posts
Default

could he not use directed broadcasts on the routers attached to the LAN,s that contain WOL hosts
Old 13 January 2011, 08:52 PM
  #16  
HHxx
Scooby Regular
 
HHxx's Avatar
 
Join Date: Nov 2001
Posts: 2,576
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by hodgy0_2
could he not use directed broadcasts on the routers attached to the LAN,s that contain WOL hosts
Ah, I see.

Well there can't be that many subnets? Just have to find them all at least once and fire off the packet to all broadcast addresses for those subnets?
Old 17 January 2011, 07:00 PM
  #17  
mike1210
Scooby Regular
Thread Starter
 
mike1210's Avatar
 
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes on 0 Posts
Default

Hodgy, HHxx

Many thanks for the pointers

I'll see if networks will let us intergrate the database

Networks have tweaked the ACL's to allow the machine that wakes up other machines to send magic packets across VLAN's, no other machines are allowed to do this.

I think networks would give us the IP map as it were, but we wanted it to be dynamic so to speak as VLAN's are altered from time to time.

Ill have a word with networks.

Mike
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JimBowen
ICE
5
02 July 2023 01:54 PM
jonc
Non Scooby Related
58
02 November 2015 03:37 PM
ALi-B
Other Marques
18
28 September 2015 08:29 PM
Stef
ScoobyNet General
44
09 November 2000 06:40 PM
IWatkins
ScoobyNet General
1
24 October 2000 10:46 AM



Quick Reply: Obtain subnet mask of host



All times are GMT +1. The time now is 05:38 PM.