Unless you use uPnP, which most routers I’ve come across recently support.
Speaking of which, does anyone know of a decent uPnP library for Java? (Just the Internet Gateway Device profile, not the rest of it). I was thinking of writing one, but the uPnP specs seemed designed to confuse me.
At one point I was toying with the idea of ripping the uPnP support from the Azureus bittorrent client… it is at least a reference implementation that you might learn the protocol from.
I’ve actually found the relevant part of the uPnP spec now! Unfortunately I haven’t got the time to do a proper IGD implementation. I’ve looked at cyberlink uPnP for Java (which is BSD license), which provides the framework but no profiles. It uses its own HTTP implementation, which seems a little odd - although it is ported from a C++ version I think.
OK, I had a sudden urge to write a UPnP control point in Java. It still needs some work, but it can do port forwarding. And in theory it can control almost any other UPnP device, but I’ve written a simple wrapper that makes port forwarding easy.
Hopefully I can get it a bit more polished and release it for general consumption sometime in the next few days!