Many guides explain how to setup a Raspberry as a Time Capsule. Time Machine needs a different protocol, so you need to install netatalk (see below). To support the two IPs, you should be able to add the share twice using the different IPs—Time Machine supports multiple backup destinations; but making this share a public service doesn't sound a good idea. I would consider setting up a VPN instead and backing up over the VPN.
Finally, to add a Time Capsule by IP (instead of relying on Bonjour), you just need to mount the partition read/write to make it visible. To mount it, use Apple+K in Finder and type as address
afp://Your_Raspberry_IP. For instance, if the IP of the Raspberry is
192.168.0.3, then type
afp://192.168.0.3. Connect to the server and mount the volume with the Time Capsule share.
To install netatalk, I've followed this guide on Raspbian:
I've used netatalk 3.0.2, and things worked mostly quite well.
However, I would suggest a few changes:
Don't use HFS as the file system, as it's not extremely well supported by Linux (no journaling support for instance, not the most stable code out there). Netatalk can share any filesystem, so probably using, say, ext4 would be better. But I didn't try this. If you do use HFS, ensure you're using at least Linux 3.4.
To speedup the initial sync, you can connect the Raspberry Pi to your system using an Ethernet cable - that'll be faster than using, say, 802.11g (standard 54Mbps wireless).
Before compiling netatalk, to install needed dependencies the guide suggests:
# apt-get install avahi-daemon libavahi-client-dev libdb5.3-dev db-util db5.3-util libgcrypt11 libgcrypt11-dev
but one should also install
# apt-get install libevent-dev
A copy of that library is included in netatalk, but is older than the one available in Debian. The call to configure becomes then:
$ ./configure --with-init-style=debian --with-zeroconf --without-libevent
after which one can invoke
make as in the guide.