locked
Assigning an IP to self contained app RRS feed

  • Question

  • User-1204637165 posted

    Please I have a web application packaged has a self contained app.  I set the application to run with random ip address in my appsettings.json file.

    "http://0.0.0.0:85".   My biggest challenge now is my client software. The software that connects to the web api server. Is it possible to assign a custom domain in my Host.File so that I can have my client software connectt to a custom domain. such has  jideakinsman.com.

    Becos sometimes the server computer can have random ips depending on the router that it is connected to.

    How do you think I can solve this problem.

    Thursday, August 1, 2019 4:00 PM

Answers

  • User475983607 posted

    Please I have a web application packaged has a self contained app.  I set the application to run with random ip address in my appsettings.json file.

    "http://0.0.0.0:85".   My biggest challenge now is my client software. The software that connects to the web api server. Is it possible to assign a custom domain in my Host.File so that I can have my client software connectt to a custom domain. such has  jideakinsman.com.

    Becos sometimes the server computer can have random ips depending on the router that it is connected to.

    How do you think I can solve this problem.

    DNS is the standard solution.  Otherwise, you'll need to write your own version of DNS where the server informs the clients or any IP changes. 

    NetBEUI (Windows) might work out if the machines are on the same network.  Basically, you can write a socket program that asks the server what its IP address is by server name.

    https://en.wikipedia.org/wiki/NetBIOS

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 1, 2019 5:31 PM
  • User-474980206 posted
    While you can use a host file instead of dns, it’s the host file on the clients that need to be updated, not the server. Most dhcp servers can be configured to use a static ip for a given MAC address. Mac addresses are unique NIC cards, but assigned to virtual networks like a VM.

    If you really can not configure the local network, then I’d use udp broadcast messages to find the server, though the routers may need to be configured to pass them to subnets.

    Also using port 85 may require opening firewall ports.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 2, 2019 12:37 AM
  • User711641945 posted

    Hi InspiredJide,

    You could specify the host name as your domain and get the IP address like below:

    string HostName = "YourHostName";
    //Dns.GetHostName().ToString();
    IPAddress[] IpInHostAddress = Dns.GetHostAddresses(HostName);

    And about configuring dns server,you could refer to: https://www.vultr.com/docs/setup-a-dns-server-on-windows-server-2012

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 6:28 AM

All replies

  • User475983607 posted

    Please I have a web application packaged has a self contained app.  I set the application to run with random ip address in my appsettings.json file.

    "http://0.0.0.0:85".   My biggest challenge now is my client software. The software that connects to the web api server. Is it possible to assign a custom domain in my Host.File so that I can have my client software connectt to a custom domain. such has  jideakinsman.com.

    Becos sometimes the server computer can have random ips depending on the router that it is connected to.

    How do you think I can solve this problem.

    DNS is the standard solution.  Otherwise, you'll need to write your own version of DNS where the server informs the clients or any IP changes. 

    NetBEUI (Windows) might work out if the machines are on the same network.  Basically, you can write a socket program that asks the server what its IP address is by server name.

    https://en.wikipedia.org/wiki/NetBIOS

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 1, 2019 5:31 PM
  • User-1204637165 posted

    This is the option have been trying Basically, you can write a socket program that asks the server what its IP address is by server name. So my first task is to write an application that checks for the IP address of a system on the network. So I can ping each of them and figure out which of them is the server. But how do I name a server. Are you referring to the name I put in the Host.File.

    Thursday, August 1, 2019 7:31 PM
  • User-474980206 posted

    how you name a server depends on what software you are using for network directory services. as suggested, DNS is the most common. in this case you register the cname/ipaddress combo. Its common to have a dhcp service that updates the DNS server. this would use the servers hostname. 

    windows supports a peer network browser that uses netbios. in this case, you assign the netbios name in windows. OS/x support bonjour which is also a local network naming service. 

    you can use the client (box connecting to the server) host file to specify the servers name/ipaddress combo.  

    most dhcp servers (which you are using to assign the ipaddress) support static ipaddress. in this case the ipaddress is based on the mac address.

    note: a self contained app just means the .net core runtime is included with the app, and has no impact on ipaddress support.

    Thursday, August 1, 2019 8:06 PM
  • User-1204637165 posted

    I tried assigning  a Host name to my computer pc.

    134.2.2.1 jideakindejoye.com

    I kept this line above in my Host.File.

    But when I try to browse my server name. it tells me ip can not be determined or obtained. So I am looking for a way I can assign a name to my server computer in such a way that any time I ping it from on system on the network. it would be publicly accessible. So I can write a code to get ip from the client system.

    Thursday, August 1, 2019 8:50 PM
  • User-1204637165 posted

    In honesty for now I dont have any software I am using for network directory services. This problem is something I encounter after I deployed at the client site.  I noticed the client could not connect to the server any more. When I investigated, I discovered that IP address had changed. So I started think of ways that the client can requery all the systems in the network and reconnect back to the server any time the IP address changes.

    I guess I would have to look at netbios.  I would also love to konw if machaddress of system change dynamically. or are they static.

    "note: a self contained app just means the .net core runtime is included with the app, and has no impact on ipaddress support."

    Yes I figured this out, so what I did was in my self contained .net core app. appsettings.json. I specified my host url to

    "hosturl": "http://0.0.0.0:85",

    So this means that if I get the ip of the server computer. I would connect the client to port 85. I would be able to access the self contained app on the network on the IP address of the server computer via port 85.

    So biggest challenge is always keeping client aware of the IP address that the server is taking, to avoid any disconnect in the present or future.

    A friend adviced I deactivate dhcp. and configure server to have a static IP. so at any time the client is connecting they connect to that know IP which never changes.

    So which ever router the system is connected to new IP would not be reassigned. But I personally would have preffered allowing the system the flexibility to pick a random IP and making the client smart enough to detect new IP address of the server and reconnect any time there is a change.

    Thursday, August 1, 2019 10:31 PM
  • User-474980206 posted
    While you can use a host file instead of dns, it’s the host file on the clients that need to be updated, not the server. Most dhcp servers can be configured to use a static ip for a given MAC address. Mac addresses are unique NIC cards, but assigned to virtual networks like a VM.

    If you really can not configure the local network, then I’d use udp broadcast messages to find the server, though the routers may need to be configured to pass them to subnets.

    Also using port 85 may require opening firewall ports.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 2, 2019 12:37 AM
  • User-1204637165 posted

    Thanks what kind of port would you advice aside port 85.

    Thanks alot.

    Friday, August 2, 2019 2:33 PM
  • User-1204637165 posted

    Hi Bruce, I think I like your udp broadcast messages solution.  So my client is built on java. I am thinking of creating a simple Java Udp Multicast system that would be placed on the server computer. So any time the system notices a change in IP address it would join the UDP Multicast server and get a Broadcast of the new IP address.

    "though the routers may need to be configured to pass them to subnets. "

    I am just abit concerned about this statement above. This solution seems abit very straight forward.

    Friday, August 2, 2019 3:11 PM
  • User-1204637165 posted

    Hi Bruce,

    Is it possible for me to Send a udp broadcast from asp.net core web api. Cos currently I have been able to write a demo code but both are written in java to send a boardcast of the servers IP address to the client software with the same LAN.

    So I just want to know if I can initiate it from asp.net core web api. Thanks alot.

    Friday, August 2, 2019 7:41 PM
  • User711641945 posted

    Hi InspiredJide,

    You could specify the host name as your domain and get the IP address like below:

    string HostName = "YourHostName";
    //Dns.GetHostName().ToString();
    IPAddress[] IpInHostAddress = Dns.GetHostAddresses(HostName);

    And about configuring dns server,you could refer to: https://www.vultr.com/docs/setup-a-dns-server-on-windows-server-2012

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 6:28 AM