is a given IP adress local

is a given IP adress local

Post by Vik Heyndrick » Sat, 16 Sep 2000 04:00:00



Hi,

Don't know whether this is the most appriopriate forum to ask, but I'll risk
it :)

I'm developping a linux networking app. (kernel 2.2.0+), using the default
sockets implementation offered by linux. I'm using C, and TCP/IP.

Two questions (somewhat overlapping, but I'm not sure if it is necessary to
know all of 2 to know 1):
1. how can I (=what is the best way to) know if a given IPv4 address is the
IP address of one of the local network interfaces (, or that is is not a
local IP address).
To get this information I do not want to make a TCP connection to any remote
machine (because I am not necessarily able to do so at the time I want this
to know), I do not want to peek in '/proc', and I do not want to run a
program from my program (like ifconfig).

2. how can I create a list of all local IP addresses.

Thanks,

--
Vik

 
 
 

is a given IP adress local

Post by Hartmann Schaff » Sat, 16 Sep 2000 04:00:00




> ...
>1. how can I (=what is the best way to) know if a given IPv4 address is the
>IP address of one of the local network interfaces (, or that is is not a
>local IP address).
>To get this information I do not want to make a TCP connection to any remote
>machine (because I am not necessarily able to do so at the time I want this
>to know), I do not want to peek in '/proc', and I do not want to run a
>program from my program (like ifconfig).

have a look at the meaning of NETMASK.  basically, any ip address that
is identical to yours in the area identified by the netmask is on the
local network interface.

Quote:>2. how can I create a list of all local IP addresses.

what exactly do you mean?  any ip address with the same NETMASKed
portion is a local ip address (exept for the net and the broadcast
address).  if you want to know all ip addresses that have an interface
assigned to them, i think there is a way to ask your dns server for a
list.  all ip addresses that are currently connected?  no way except
going to the net and find out (the other machines have to be
cooperative, though)

hs

 
 
 

is a given IP adress local

Post by Vik Heyndrick » Sun, 17 Sep 2000 04:00:00



Quote:> have a look at the meaning of NETMASK.  basically, any ip address that
> is identical to yours in the area identified by the netmask is on the
> local network interface.

I think you misunderstood. My program does not know what the running host's
IP address is. I just want to find out without calling a program. Is such a
thing possible using socket programming?
 
 
 

is a given IP adress local

Post by Vik Heyndrick » Sun, 17 Sep 2000 04:00:00




Quote:> if (ioctl(s,SIOCGIFCONF,&ifconf)==-1) {

Thanks a lot!

_Exactly_ what I was looking for :)

Kind regards,

--
Vik

 
 
 

1. DIP: How to obtain local IP-adress

I am trying to set up DIP to dial up to my internet provider.
Everything seems to work OK, except for the part where I get my local
IP adress. (It is dynamic). Below is a copy of my chat script and the
output to the terminal window.

chat script:

        netmask 255.255.255.0
        port modem
        speed 19200
        reset
        dial xxxxxxx
        term
        get $remote 145.220.7.5
        get $local remote
        default mode PPP

term. window:

        User Access Verification
        Username:
        password:
        Entering PPP mode
        Async interface adress is unnumbered (ethernet0)
        Your IP-adress is xxx.xxx.xxx.xx. MTU is 1500 bytes
        Header compression will match your system.

When the script reaches the get $local remote line it pauses for two
seconds before it prints "local set to default".  (Probably 127.0.0.1)
Ping 145.220.7.5 gives me a "network not found error"

If anyone knows the answer please help,

Peter

===================
name: Peter Middelkamp

===================

2. will linux run on this computer?

3. how to find my own local IP-adress?

4. Question about shared library and ahmmax

5. how to get ip adress of MX host for some email adress

6. Upgrading Sendmail

7. Prevent access to linux server when mac adress does not match ip adress

8. make and pwd

9. dynamic ip-adresses to fix adresses

10. 2 ip adresses, different subnet, ping reply from ip in other subnet ?

11. How to find IP name knowing IP adress?

12. two IP adresses/new IP-address

13. DNS-local adress resolution