Skip to contentSkip to conversation

Translating between local and global IP address

DISCUSSION Lars Brinkhoff 1 participant 1 message Jan 22, 2003

lore
Share & tools
lore
#0 lore raw

Hello,

My home network is set up something like this:

                    internet
                       |
                      eth0
                  GATEWAY (Linux)
                      eth1
                       |
                 COMPUTER (Windows)

COMPUTER has a local IP address ($IN), but I'd like to mangle packets going through GATEWAY so COMPUTER appears to have another IP address ($OUT) on the internet. It seems I've had some success with this:

  iptables -t nat -A POSTROUTING -o eth0 -s $IN  -j SNAT --to-source $OUT
  iptables -t nat -A PREROUTING  -i eth0 -d $OUT -j DNAT --to-destination $IN

And to fool GATEWAY into accepting packets for $OUT, I've done this:

ifconfig eth0:1 $OUT

However, it doesn't seem to work when trying to play a network game on COMPUTER. It times out trying to connect to another machine on the internet. It probably uses UDP packets.

Any idea what I'm doing wrong?

Thanks.