Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to route traffic from a device (that I will call "target") connected to my Ubuntu box (that I will call "host") to servers at a remote office.

The host uses a Racoon IPSec VPN, connected through a NIC called efix. This creates an aliased IF called efix:0 which has IP adress It is able to reach the servers.

The link between host and target is an Ethernet link, using IP adresses on IF eusb for the host and on IF eth0 for the target.

I have setup the following routes and iptables entries:

  • On target: * U  0 0 0 eth0
    default       UG 0 0 0 eth0
  • On host:

    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -s -j SNAT --to
    iptables -A FORWARD -s -j ACCEPT
    iptables -A FORWARD -d -j ACCEPT

Using Wireshark to monitor an HTTP GET, I can see SYN packets from the target go all the way to the server, but the server's SYNACK packets stop at the host and are not forwarded to the target. Am I missing something here ? Isn't SNAT supposed to keep track of the connections ?

share|improve this question
After some more reading: could the racoon IPSec stack be the issue here ? My connexion script only establishes tunnels between the remote VPN gateway and the host machine, maybe I should add a tunnel for the segment ? – Mithfindel Sep 28 '11 at 8:32

Your problem is likely that your forward rule is relying on the SNAT to have already happened for the return packets. When you say `iptables -A FORWARD -d", that relies on the traffic already having been changed via the NAT, which happens after the forwarding. When the initial packet comes in, it has the NATed IP address ( as the destination.

Probably what you want are rules like this:

iptables -A forward -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A -i efix -j ACCEPT
iptables -t nat -A POSTROUTING -s -j SNAT --to-source

The first rule allows traffic related to existing connections, like the return traffic from the SNATed connections from "host". The second accepts traffic from "host" (if I understand your layout, "host" passes traffic to your NATing firewall on it's "etho0" interface, right?). You may further want to limit that rule with "-d", depending on your exact needs.

The last rule is what you have already posted, which says to SNAT the traffic.

share|improve this answer
My layout description might not be as clear as I thought. The layout is: VPN <=> <=> – Mithfindel Sep 28 '11 at 8:27
Ok, changing answer to reflect that. – Sean Reifschneider Sep 28 '11 at 21:47

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.