1

I have a device (an IP phone) that only allows an explicit IP address to contact the remote server. However, the IP address of the remote server can change (it's dynamically assigned).

I figure there must be a way to connect the IP phone to an inexpensive router that would be able to do this mapping but I have no idea how I might go about this because (as far as I know) the rules you specify in a router also use hardcoded IP addresses.

Anyone know how to do this? Guidance would be very much appreciated.

David
  • 299
  • 3
  • 8
  • 2
    In general, you use names to resolve IPs at run-time, but not really the reverse, so most network client libraries will not attempt a lookup of any kind if they are provided the IP. To change that behavior you would need access to the code, to perform a reverse lookup on the ip to get the name, and a forward lookup to get the ip DNS associates with the name. that way you could use a host file to resolve the reverse lookup to get the name and then use it for forward resolution. but then again, you would be able to change the hardcoded IP if you had access to source and the compilation tools. – Frank Thomas Jul 01 '15 at 23:25
  • And if pigs had wings they could fly! I understand one normally converts names to IP addresses, but my situation is exactly as I describe and I'm not in a position to get at the firmware in the IP Phone. – David Jul 02 '15 at 03:27
  • shouldn't just editing the hosts file (works on Linux and Windows) help: IP.OF.PH.ON.EX Alternative.Hostname – ljrk Jul 02 '15 at 05:58
  • @David, I've been misunderstanding what you meant by "Hardcoded" or "explicit" IP. Thats good though, because in that case, I can think of a few ways to pull it off, but neither will be simple and both will cost at least some money (DDNS providers are reasonably cheap). Still its better than if the programmer had written it to use 239.44.55.66 and it could not be changed. – Frank Thomas Jul 02 '15 at 07:21
  • I already have DDNS support available. The issue is how to to configure a router (and I'm happy to buy one dedicated to the phone) so that an incoming static IP address (from the phone) can be mapped to some other IP address via name, so that the mapping will update as that second IP address changes – David Jul 02 '15 at 12:26
  • Actually for the purpose of this problem, you could assume that the programmer had in fact written the IP hard coded to 239.44.55.66. In this case the router would be configured so that the LAN is that subnet (239.44.55/24) and the problem is how to transform that IP address on that subnet to a potentially changing target IP address – David Jul 02 '15 at 12:29
  • 1
    @David, 239.44.55/24 is a Multi-cast group address and is handled differently than host addresses. My computers in the 192.168.xx.0/24 space often communicate with Multicast by crafting packets in the 239.x.y.z space, and the multicast group is overlayed on the actual 192.168.xx.0/24 network. That may be why you are having trouble with the router option. https://en.wikipedia.org/wiki/IP_multicast – Frank Thomas Jul 03 '15 at 08:31
  • @frank you misunderstood. I only referred to that IP address because you did. It didn't mean anything to me. There's no computer involved here. Just a phone with a hardcoded IP address (I can choose any address I want). So to simplify the problem for the moment, suppose the phone has a target server address of 1.2.3.4. However, the actual server address is 5.6.7.8 (forget for a moment that it can change). How can I configure a router so that incoming packets with a target address of 1.2.3.4 can be changed so that the packets going out of the router will have a target address of 5.6.7.8? – David Jul 03 '15 at 13:56
  • The obvious real solution seems to never use the awfully written software which doesn't allow to specify hostnames. If this is not possible, you *have* to use a fixed IP address for the server — this is the *requirement* of your software setup, and I'd not consider attempts to circumvent it. – Nikita Kipriyanov Nov 14 '21 at 07:52
  • I'm not talking about the server --- I'm talking about the clients. It just seemed to me that there ought to be a way for a router to receive packets from a device with a specific destination address and change those packets on the fly to use a different destination address (and of course the reverse when responses come back) – David Nov 30 '21 at 14:48

3 Answers3

1

Ahh, I understand, you can only use dotted-decimal format for the PBX address.

Usually, in the programming world, a "hardcoded IP" is a specific address written directly into the code, and cannot be changed at all. Sorry for the confusion.

In this case that does open up some options, including a VPN or a VPS running a Reverse Proxy, in combination with a Dynamic DNS provider (and a router that supports it). you may not need to travel with a router at all.


Provided your phone supports a VPN client, you can establish a VPN connection to a DDNS name that points to your home network. that will connect your phone to your LAN as though you were directly plugged into it. you can then access the PBX server by its private address on your LAN. If your phone does not support a native VPN client, you could use a cheap router at your location to create a site-to-site VPN link to home on the phones behalf.

so consider this scenario:

home public IP: 1.2.3.4
DDNS name: pbx.mynet.net --> 1.2.3.4
PBX IP: 10.0.1.1

you would set up a VPN on your router, and connect the phones VPN client to 'pbx.mynet.net', and in your IP phones PBX server address you would set 10.0.1.1.

|phone| >10.0.0.1>  {|VPN| >pbx.mynet.net=1.2.3.4> |router|} >10.0.1.1> |PBX|

Another option would be a VPS, with a public IP. you would set up a reverse proxy to redirect traffic on port x to your DDNS name.

LAN public IP: 1.2.3.4
VPS IP: 4.3.2.1
DDNSName: pbx.mynet.net --> 1.2.3.4
proxy redirect:  :1234 --> pbx.mynet.net:1234
PBX LAN address: 10.0.1.1

You would point your phones PBX server address to 4.3.2.1. when the VPS receives the packets, it will forward them to 1.2.3.4, and your port forward rules will forward the packets on to the PBX server.

|phone| >4.3.2.1>  |VPS| >pbx.mynet.net=1.2.3.4>  |Router NAT| >10.0.1.1> |PBX|
Frank Thomas
  • 35,097
  • 3
  • 77
  • 98
  • It doesn't support VPN. i have already experimented with site-to-site VPN and have that working. But I want a solution where I can just carry the phone and router somewhere, plug them in to a hotel wifi (say) and have its IP address mapped dynamically. So far the only thing I can think of (just based on initial reading) is a ddwrt-based router win an ip table rule that can be updated dynamically. But how would I actually do this? – David Jul 02 '15 at 12:34
  • why can't you do site-to-site VPN between your on-the-go router and your home router? The VPS option is also viable, and doesn't require you carry the router, but does incur an additional monthly cost. – Frank Thomas Jul 03 '15 at 08:23
  • I've done site to site VPN and hat works fine. However not everyone who will need this device will be in a position to do this. So I'd really like to understand how I could do it by directly mapping one ip to another. To be honest, I'm rather surprised that this is seemingly so difficult to do (based on not getting any answers). I would have thought this to be an easy problem for anyone who understands networking deeply. – David Jul 03 '15 at 13:48
-1

I believe this could be achieved by using SNAT, ie. source-NAT, by giving one router-port (virtual or not) IP-address 10.0.1.1 and setting SNAT on it to your public IP-address. OpenWRT does have a clean, browser-based UI for doing all this and you can read about the settings and such on their website at https://openwrt.org/docs/guide-user/firewall/firewall_configuration

Disclaimer: I have never used a SNAT myself and can't offer much more than this.

WereCatf
  • 101
-1

I have never tried it, however I have read that you can use PTR records to map IP addresses to hostnames :

http://www.itworld.com/article/2833006/networking/how-to-setup-reverse-dns-and-ptr-records.html

http://help.dnsmadeeasy.com/managed-dns/dns-record-types/ptr-record/

Also, if your home router doesn't support it, maybe you can flash DD-WRT firmware on to it, and give yourself more routing options. Failing that, you could build your own router and implement your own PTR records that way.

Hope this helps!

  • Hmm, seems very strange to have a server with a dynamic IP. If the OP has control over the server, and setting it static is not an option, then maybe some no IP service on the server could be implemented so the IP address changes can be easily resolved. Of course, it's a manual job to change the IP phone every time.... – OutOfThisPlanet Jul 02 '15 at 00:30
  • 1
    @Frank The issue is indeed that the IP Phone will only allow me to specify the address of the remote server in standard IP4 format. It doesn't allow me to enter a hostname. – David Jul 02 '15 at 03:23
  • @Nulldata The server in a question is a PBX in my basement, and is part of my home LAN. I have one external IP address given to me by my ISP and incoming packets on particular ports are forwarded to that PBX. Technically, it's the external IP address that can change but that detail didn't seem necessary for the problem at hand. One of my linux boxes runs an IP checker and updates DNS records if my external IP address does change. – David Jul 02 '15 at 03:25
  • @Nulldata Getting another router is not a problem, indeed nor is putting DD-WRT on it. Happy to spend a little money on that. Indeed one goal is to be able to take that IP phone and router with me when I travel. The thing is, getting a router/DD-WRT is one thing. I still don't know WHAT I would need to do to actually make the thing work. That's why I asked for some help. – David Jul 02 '15 at 03:30
  • I'm reading about DD-WRT and ip-tables. It looks like you can specify a hostname in an ip-table rule but the hostname only gets resolved when the rule is created. However, I see that it's also possible to run cron scripts inside DD-WRT. If that's the case, I'm wondering if I could create an IP rule that maps an incoming address to a hostname and have a cron job check the hostname IP address from time to time and if it changes, then delete/reinsert the IP-TABLE rule. Would that work? – David Jul 02 '15 at 04:09