# Adding a looping network address

## haarp

Greetings.

I have this game server that is quite buggy. It expects the machine's IP address to also be the external (Internet-facing) IP address to work properly. My machine however is behind a router. Therefore (assumption: 123.123.123.123 is my external address):

Internet<---[123.123.123.123]Router[192.168.0.1]--->[192.168.0.2]machine

The application binds to the interface behind 192.168.0.2, which introduces a bug (basically, the clients can't see the server ping in their server browsers)

So my plan is to add a new pseudo-interface with 123.123.123.123 as its address to machine, as if it was hooked up to the Internet directly. The game server can then bind to this interface.

This pseudo-interface would have to behave in a way that routes traffic the same way the regular interface would. I've been playing around with ip and iptables and all kinds of tools from random google searches, but I couldn't come up with any working solution.

Any ideas?

----------

## Hu

It sounds like it would be much easier to patch the game server to read the correct address from a global variable, which you then initialize on the command line.  The solution you propose seems like it would require having two machines with the same IP address, which often causes many problems.

----------

## haarp

 *Hu wrote:*   

> It sounds like it would be much easier to patch the game server to read the correct address from a global variable, which you then initialize on the command line.  The solution you propose seems like it would require having two machines with the same IP address, which often causes many problems.

 

That is true. However, it's a closed source Windows application running under Wine. Not much I can do  :Wink: 

----------

## Hu

That makes it a bit more difficult, but still quite viable, to patch it.  Use LD_PRELOAD to shadow getsockname and return the useful value.  You could also try to patch Wine's implementation of Winsock, but the LD_PRELOAD trick would be quicker to write.  You can probably use sys-apps/sandbox as a reference.

----------

## haarp

Thanks, the idea sounds good.

I had a look at sandbox. I understand what it does (intercept calls and examine them), but implementation is a good deal beyond my abilities  :Sad: 

----------

