Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3283430
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:02:27+00:00 2026-05-17T20:02:27+00:00

I am wanting to get the users IP address (the logged in user will

  • 0

I am wanting to get the users IP address (the logged in user will be running the application under there user context on there local PC), but many PC’s in our environment have multiple NIC’s that have been added by VMWare Workstation, I would like to exclude these type of bridged connections and only show the “primary” NIC on the PC.

The following function will get the IPv4 address, however on my test PC it is returning the bridged connection and not the IP Address of the network facing NIC.

 Shared Function GetIP(ByVal computerName As String) As String
    'Dim ipEntry As IPHostEntry = Dns.GetHostEntry(computerName)
    'Dim tmpAddr As IPAddress() = ipEntry.AddressList
    Dim ipAddress As String = ""
    'Dim i As Integer = 0
    'Do While i < tmpAddr.Length
    '    If tmpAddr(i).AddressFamily = Sockets.AddressFamily.InterNetwork Then
    '        ipAddress = tmpAddr(i).ToString
    '    End If
    '    i += 1
    'Loop
    Dim ipentry As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry("")

    For i As Integer = 0 To ipentry.AddressList.Count - 1
        ipAddress = System.Net.Dns.GetHostEntry("").AddressList(i).ToString
    Next

    Return ipAddress
End Function

My users have a mixture of DHCP and static addresses so cannot limit the NIC to either of these connection types. We tend to have a 172.16.x.x IP range, so is there a way to modify the above function so that it will only return a 172.16.x.x address?

Your assistance is greatly appreciated.

Thanks,

Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:02:27+00:00Added an answer on May 17, 2026 at 8:02 pm

    You could always use

    If ipAddress.ToString().StartsWith("172.16) Then
      ' Now you've got a match
      ipAddress = tmpAddr(i).ToString()
    End If
    

    Of course, my code is bad because you’re calling .ToString() twice, which could be a performance drag if there are a lot of addresses to parse, so you may want to modify it slightly…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still learning Ruby, and get caught up in alot of the 'magic', wanting
I'm trying to do something that I thought was simple but doesn't appear to
We are wanting to modify our app and create a way to allow mobile
I'm using Paperclip to handle avatar's for users and currently set a default image
Rails has a very convenient uniqueness validation. ASP.NET MVC doesn't. I need to make
I'm looking for the best solution on how I can ensure I am doing
Following the instructions here: https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-(Windows ) I've tried installing on two machines, either of
My website is suffering from an apparent bot which GETs a particular URL 5
I am using a port scanner to scan my subnet. The port scanner unfortunately

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.