Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Ipaddress

 

Hi, i am tring to get IPaddress of my machine.

So far I made it. the problem is, I get 2 IPs. One IP is the local Area connection and the other is the PPP adapter.

How do I get the PPP adapter?

Posted

How to Get IP assigned by RAS

 

This is the same problem i am facing, i am developing an application in which i want to check the IP address which is assigned by the RAS server ,

but i am unable to do so coz when i try to resolve the

 

localhost it returnes 127.0.0.1 but in case of this

 

 System.Net.Dns.Resolve(SystemInformation.ComputerName)

 

it returns me 192.168.0.2 which i my currently IP with network card.

 

 

Is there any way to check which IP address assigned by Romote Access Server ?

The one and only

Dr. Madz

eee-m@il

Posted

Re: How to Get IP assigned by RAS

 

Madz, this is the code to obtain the Loacal Machine IP.

 

 
using System;
using System.Net;

   static void Main(string[] args) {
     string machine_name = Dns.GetHostName();
     IPHostEntry host = Dns.GetHostByName(machine_name);

     for (int i=0; i < host.AddressList.Length; i++){
       Console.WriteLine(host.AddressList[i]);
     }
     Console.ReadLine();
   }

 

host.AddressList[0] is the Local Area Connection IPaddress.

host.AddressList[1] is the PPP IPaddress.

You can use the host.AddressList[1] but can you be sure that in all of the machine you'll get the PPP IPaddress in the second field?

I am not. If there's other way to write in the code that the computer will give you only the PPP.

Posted

THanks for you help dear

Actually my application is that type when ever my application starts it should check Ipaddress assigned by RAS. if it belongs to it's own lease it should run the application otherwise it would be closed.

First we implemented with RAS Dialer Utility but people were able to access application by changing Fone number in the RAS Dial up entry .

we were trying to get some method that application would not be able to run unless pc have an ip of allowed list

The one and only

Dr. Madz

eee-m@il

  • *Gurus*
Posted

I had to do this to get active-mode FTP working the other day. The trouble is, I already had a connection to a host over RAS so it was straightforward to check the Socket's LocalEndPoint property.

 

Perhaps you could do something like that if you find no other way.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Sorry, I didn't understand your answers,guys.

Is there a way to get only one IPaddress in a list of IPaddresses?

Maybe Some thing like:

 

host.AddressList.ByName(PPP); ?

 

What is RAS?

Posted

Well that's strange coz in case we develop our own RAS (Remote Access Server) dial up utility then with that we can get IP address assigned by RAS.

but this is entirely different case, our system is already connected to 2 different netowrks 1, local and second is assigned by Remote access server.

on every PC it;s first preority is toward its local netowrk that;'s why when we try to get Ip addresses it shows first IP address assigned to network card. and after that some external.

The one and only

Dr. Madz

eee-m@il

Posted

I cant say exectly about that. if your Network Card has 2 IP then the 2nd one would also be it's other Ip address assigned to netowrk card, and at the end it would be PPP address

I think at the end of search it shows the PPP IP.

The one and only

Dr. Madz

eee-m@il

Posted

I did mistake

 

I have checked and confirmed. the code you have written

 

using System;
using System.Net;

   static void Main(string[] args) {
     string machine_name = Dns.GetHostName();
     IPHostEntry host = Dns.GetHostByName(machine_name);

     for (int i=0; i < host.AddressList.Length; i++){
       Console.WriteLine(host.AddressList[i]);
     }
     Console.ReadLine();
   }

 

And it gave me this Result

 

192.168.0.2

202.154.239.40

192.168.0.31

 

in these results

 

First one was ip assigned to my network card

Second one was PPP ip

and the last one was the another Ip address assigned to my Netowrk Card

 

I hope now it would be clear that the 2nd Entry is PPP dial Up.

 

Can any one explain, In which Sequence a System Saves it;s IP entries ?

The one and only

Dr. Madz

eee-m@il

Posted

The 2nd Entry is PPP dial Up only if there are more then 1 IPaddresses?

What if there are more then 3,4 or 4?

We need to get a better understanding about it.

Isn't there any property that holds a string that contains the name or describes the IPaddress

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...