Results 1 to 13 of 13

Thread: Get Public IP Address Without Use Of External Website

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Get Public IP Address Without Use Of External Website

    I searched high and low but could not find any simple way to get my public IP address without using an external site.
    You would think that there is a simple way to do this very basic function but I can not seem to find one..
    I have been losing my mind trying to find a simple answer but no simple answer seems to exist.

    isn't there some built in vb .net function to do this?

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Get Public IP Address Without Use Of External Website

    Quote Originally Posted by DreamWarrior77 View Post
    isn't there some built in vb .net function to do this?
    How could there be? How would any programming language have a function that would know how to find this information from any number of possible brands/types/layers of network gear?

    Sometimes to see how others see you you need to look in a mirror.

    Unless this is something you are working on for personal use that you can hardcode some sort of web scraping function that interacts with whatever device you have that holds your public IP address (assuming whatever device you have that holds your public IP address has a web or other interface that your code could connect to), I think you're stuck with going out to the net to see how others see you.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Re: Get Public IP Address Without Use Of External Website

    well I am trying to make a server/client set of programs that will need to connect to each other. How can they connect if I don't have their IP addresses?
    I would assume that you couldn't..

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Get Public IP Address Without Use Of External Website

    The server would have to have a known address, and then the client can connect.
    The server would then know the client address to use to reply.
    You would ask your ISP provider to provide a static address for you as the server, no doubt at an extra cost.
    Or you could use another external service to provide a static address, and you connect to it through a fixed address, and packets are relayed through the service.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Re: Get Public IP Address Without Use Of External Website

    How would any programming language have a function that would know how to find this information from any number of possible brands/types/layers of network gear?
    Because it is Windows OS, it should be able to achieve this rather easily in fact. I don't see why it should not be able to..
    it's called dot "net" for a reason, so programmers can connect to other computers via the internet (among other things)
    and we have built in things for connecting such as TCPClient and TCPServer, it just seems to make honest sense that we should be able to do this very simply
    or how else would we connect to each other?

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Get Public IP Address Without Use Of External Website

    Perhaps read some articles on the Internet to see how it works.
    In a sense they ran out of IP4 addresses years ago, so have to use NAT capabilities, so that many users can shared the same address. Those shared addresses are managed by your ISP, and your computer is also usually connected through a router so your devices, using the same router are also using NAT capabilities to share the one external IP address that your ISP is providing to you.

    So, the easiest way to find out what IP address your machine has on the internet at any given time is to connect with something on the internet and have it report back to you what the remote IP address was that connected to it at that level.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  7. #7
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Get Public IP Address Without Use Of External Website

    Quote Originally Posted by DreamWarrior77 View Post
    Because it is Windows OS, it should be able to achieve this rather easily in fact. I don't see why it should not be able to..
    it's called dot "net" for a reason, so programmers can connect to other computers via the internet (among other things)
    and we have built in things for connecting such as TCPClient and TCPServer, it just seems to make honest sense that we should be able to do this very simply
    or how else would we connect to each other?
    Good luck with that.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Re: Get Public IP Address Without Use Of External Website

    Thanks passel, so lets say I want to run a Server from home where my PC is required to run 24/7 for users to connect to..
    and I have optimum online internet service, I would know my own IP Address and then where do I go from here though?
    I mean my Client program would be hard coded to included my Server IP Address?

    What if my Server IP Address changes, how can I update the Client to reflect a new Server IP Address being required to update for the Client program itself?
    I realize that are a number of ways to go about things but what would be something easy to implement? or the most proper way of doing it?

    Also assuming that the Client connects to the Server program how does the Server find out the Client Users IP Address? What do I use here to find out the Clients IP Address?

    Thanks
    Last edited by DreamWarrior77; Aug 14th, 2020 at 09:21 PM.

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Get Public IP Address Without Use Of External Website

    Quote Originally Posted by DreamWarrior77 View Post
    What if my Server IP Address changes, how can I update the Client to reflect a new Server IP Address being required to update for the Client program itself?
    That's why you would generally use a URL and then an IP address gets mapped to that via DNS. If your server IP address changes, you update the appropriate DNS entries and the clients continue to connect via the same URL.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Get Public IP Address Without Use Of External Website

    Quote Originally Posted by DreamWarrior77 View Post
    lets say I want to run a Server from home where my PC is required to run 24/7 for users to connect to
    Check that your ISP allows that. Even if they do/will provide a static IP address, not all ISPs will allow you to run a server at that address.

  11. #11
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    557

    Re: Get Public IP Address Without Use Of External Website

    I am running my own server(s) for last 16 years, also in the office we are running own public servers (again for 16 years). Here are some hints (some of the already mentioned above):

    - Ask ISP to grant you full traffic to your router so you will have full featured real IP. Sometimes ISPs are forwarding only range of ports and you can't do some specific settings

    - Use own router as entry point and first firewall and setup router to forward ports to your server and services

    - Learn how to secure your router and what services should be disabled. Some other features are good to be enabled (e.g. firewall and PING response)

    - Setup properly the firewall on your server to have only the required ports opened

    - Regularly check for critical/security updates of all services you are running - web server, SQL server, etc.

    - Buy domain name from registrar, e.g. dreamwarrior77.com

    - Setup the domain in the registrar control panel to point to your IP address. Sometimes it takes 24 to 48 hours to spread the domain name to IP link to all other DNS servers so don't rush

    - If you are not on static address, but it is dynamically changed, many domain services allow you to run tool which updates the DNS records of your domain to your current IP address. Sometimes this feature is also built into some home/office routers so you don't need to run another tool/service on your computer/server

    - Use your mobile connection for quick tests if you can access your public IP address. Also call a friend to test if the service (e.g. web server running on ports 80 and 443) can be accessed from another ISP.

    - You can use external tools (web sites) which can check your DNS and connection info how it appears for others in the world. Quick search pointed me to DNS Checker, but there are many others.

    - Check logs, monitor the services, search for security issues on your specific servers, be prepared with a backup solution if something wrong happens. And don't be afraid to stop the services for public use (e.g. disable forwarded ports or just shutdown the server) if you think someone gained access to your server.

    Good luck and don't be afraid of experimenting!

  12. #12
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    557

    Re: Get Public IP Address Without Use Of External Website

    Few more hints:

    - If you expose HTTP services, it is highly recommended to configure it to use SSL (HTTPS protocol) to avoid man-in-the-middle attacks

    - If you expose public web site, then HTTPS is really appreciated by users and they like the proper "lock" icon instead of warning icons in the URL bar in their browsers. But even you provide your own SSL certificate, the current browsers are complaining because these certificates are not known to authorities and are treated as untrusted. To get free certificate, you can use Let's Encrypt. For Windows you may use win-acme client which runs as service and automatically gets new SSL certs each 2 months (Let's Encrypt certs are valid for 3 months). There is also GitHub repository: win-acme releases

    - You may need access to your servers when you are not in the office/building where they are located and you don't have access to the internal network. VPN is the solution but take care to use something secure and having proper passwords/certificates to access it. Having VPN correctly setup and running, you can control your servers with laptop or mobile phone when you are away from office

    - Public web sites are using HTTP(S) protocols and standard ports (80 and 443). But for your app, if you are exposing web or any other service, just avoid standard ports. Use anything in the high range of ports (30000+). This won't stop scanning, but will reduce tryout attempts.

    - Remote access to Windows servers can be performed by using remote desktop services, VNC or SSH. Remote desktop requires specific versions of Windows and has some other limitations depending on licensing, etc. Free VNC servers are having some issues with security (usually non-encrypted connection). SSH is just plain command line (terminal) access but SSH can be used to access server non-public port.

    - Always avoid publicly exposed service if you need it for internal use. Better to connect to VPN and then to the service instead of forwarding the port on the router.

    These hints does not answer the question. But there is no answer how to get the public IP address via function without accessing external service. DNS is your friend and even for dynamic IP addresses, there are tools that update the DNS entries very quickly and users can access the server by name instead of numeric address.

  13. #13
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    486

    Re: Get Public IP Address Without Use Of External Website

    I believe the code you are looking for is in the the vb code bank page 5 entery 3

    George

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width