Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a server running Xen with the following network configuration

root@ubuntu:~# cat /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

auto xenbr0
iface xenbr0 inet static
    bridge_ports none

# The primary network interface
auto eth0
iface eth0 inet static

I also have

(network-script network-nat)
(vif-script     vif-nat)

enabled in /etc/xen/xend-config.sxp and masquerade set up with iptables:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

From this server I can connect to domU at SSH works, too. After sshing in, I can ping outside hosts like and my own machine at

I'd like to redirect traffic going destined for ssh on to another address and port,

This rules don't works:

 iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 2022 -j DNAT --to-destination

and this:

iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 2022 -j DNAT --to-destination
iptables -t nat -A POSTROUTING -s ! -d -p tcp -j MASQUERADE --to-ports 1024-65535
iptables -t nat -A POSTROUTING -s ! -d -p udp -j MASQUERADE --to-ports 1024-65535
iptables -t nat -A POSTROUTING -s ! -d -j MASQUERADE 

What should I do? Can I do it with iptables? If so, how?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.