Networking Forums

Networking Forums > Computer Networking > Linux Networking > Validate a gateway address!

Reply
Thread Tools Display Modes

Validate a gateway address!

 
 
Goran
Guest
Posts: n/a

 
      11-12-2004, 02:30 PM
Hello,

I need to validate a gateway address by knowing a ip address and
netmask. How do i calculate this? I want to do this in either in C or
from a shell script.

Regards,
Goran
 
Reply With Quote
 
 
 
 
Michael Heiming
Guest
Posts: n/a

 
      11-13-2004, 07:36 AM
In comp.os.linux.networking Goran <(E-Mail Removed)>:
> Hello,


> I need to validate a gateway address by knowing a ip address and
> netmask. How do i calculate this? I want to do this in either in C or
> from a shell script.


The gateway IP can be anywhere inside the subnet, 'ipcalc' is one
out of numerous apps, search "freshmeat.net" for others.

$ ipcalc -h
ipcalc: ip address expected
Usage: ipcalc [OPTION...]
-b, --broadcast Display calculated broadcast address
-h, --hostname Show hostname determined via DNS
-m, --netmask Display default netmask for IP (class A, B, or C)
-n, --network Display network address
-p, --prefix Display network prefix
-s, --silent Don't ever display error messages

Help options:
-?, --help Show this help message
--usage Display brief usage message


--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo (E-Mail Removed) | perl -pe 'y/a-z/n-za-m/'
#bofh excuse 435: Internet shut down due to maintenance
 
Reply With Quote
 
Goran
Guest
Posts: n/a

 
      11-15-2004, 11:47 AM
Thanks for the response Michael but that wasn't what i needed.
I solved it by calculate the broadcast address from the gateway
address and netmask and compare it against the broadcast address
calculated from the ip address and netmask. I think this test it's
good enough for me.

Michael Heiming <michael+(E-Mail Removed)> wrote in message news:<bltg62-(E-Mail Removed)>...
> In comp.os.linux.networking Goran <(E-Mail Removed)>:
> > Hello,

>
> > I need to validate a gateway address by knowing a ip address and
> > netmask. How do i calculate this? I want to do this in either in C or
> > from a shell script.

>
> The gateway IP can be anywhere inside the subnet, 'ipcalc' is one
> out of numerous apps, search "freshmeat.net" for others.
>
> $ ipcalc -h
> ipcalc: ip address expected
> Usage: ipcalc [OPTION...]
> -b, --broadcast Display calculated broadcast address
> -h, --hostname Show hostname determined via DNS
> -m, --netmask Display default netmask for IP (class A, B, or C)
> -n, --network Display network address
> -p, --prefix Display network prefix
> -s, --silent Don't ever display error messages
>
> Help options:
> -?, --help Show this help message
> --usage Display brief usage message

 
Reply With Quote
 
Ken
Guest
Posts: n/a

 
      11-16-2004, 03:57 AM
Hi Goran -

On 15 Nov 2004 04:47:35 -0800, (E-Mail Removed) (Goran) wrote:

>Thanks for the response Michael but that wasn't what i needed.
>I solved it by calculate the broadcast address from the gateway
>address and netmask and compare it against the broadcast address
>calculated from the ip address and netmask. I think this test it's
>good enough for me.


I would do it using the network address, not the broadcast address,
however it should give the same results if the netmasks are the same.
If the netmasks are not the same, it gets trickier as neither the
network address nor broadcast address are necessarily the same.

You might also want to check that the gateway address:

1. is not equal to the ip address.
2. is not equal to the network address.
3. is not equal to the broadcast address.

--
Ken
http://www.ke9nr.net/
 
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
IP Address is in a different subnet as the gateway address karthik Network Routers 2 04-30-2008 01:55 AM
My Router does not accept a gateway ip that has a subnet address different from the laptop ip address keethyanandpr@gmail.com Wireless Internet 15 03-18-2007 04:03 PM
How to get default Gateway address, subnet address, DNS names using C/C++ Matrixinline Linux Networking 2 01-11-2007 04:32 AM
DHCP gives client address but no gateway address mheymann Windows Networking 4 06-09-2006 12:29 PM
AP gateway Address Geoff Lane Windows Networking 5 10-07-2003 07:16 AM



1 2 3 4 5 6 7 8 9 10 11