I'm trying to use OpenVPN on Amazon Linux to connect the local LAN to a VPC on EC2. I have traffic flowing from the OpenVPN instance to any machine on the LAN, but other machines on the VPC are not seeing traffic from the LAN.

Here's a trimmed version of the network:

       Local network          /        EC2 VPC, 10.2.0.*/
  10.1.0.*/               ,'     ,'
 +---------------+   |             
 | OpenVPN on    |   |             
 |   firewall    XXX |   +---------------+
 |      |  XXXX | OpenVPN server|
 +------`.-------+   \  XX  `-.    +-------------+
          \          '.  +---------------+  `-. Second server
  +--------`.---+     |                       |   |
  |Local server |      \                      +-------------+
  |    |       \
  +-------------+        \

From the EC2 OpenVPN server:

[root@ip-10-2-0-10 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0   UG    0      0        0 tun0   UG    0      0        0 tun0 UH    0      0        0 tun0   U     0      0        0 eth0

[root@ip-10-2-0-10 ~]# ping -c 2
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=127 time=488 ms
64 bytes from icmp_seq=2 ttl=127 time=54.9 ms

--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1056ms
rtt min/avg/max/mdev = 54.925/271.767/488.609/216.842 ms

From the LAN firewall:

root@firewall:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         xxx.xxx.xxx.xxx         UG    0      0        0 eth0.2   U     0      0        0 br-lan   UG    0      0        0 tun0 UH    0      0        0 tun0   UG    0      0        0 tun0

From the Second server on EC2:

[root@ip-10-2-0-12 ~]# ping -c 3
PING ( 56(84) bytes of data.

--- ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 12014ms

However here's the kicker. Doing a tcpdump on the EC2 OpenVPN server shows all traffic flowing as it should:

[root@ip-10-2-0-10 ~]# tcpdump -i eth0 -n host
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
13:46:58.779826 IP > ICMP echo request, id 21846, seq 1, length 64
13:46:58.852756 IP > ICMP echo reply, id 21846, seq 1, length 64
13:46:59.787467 IP > ICMP echo request, id 21846, seq 2, length 64
13:46:59.847424 IP > ICMP echo reply, id 21846, seq 2, length 64

Tcpdump on the Second server on EC2 only shows the echo request and no replies.

  • IPtables firewalls are disabled on all EC2 instances.
  • IP forwarding has been enabled on the OpenVPN server.
  • The EC2 security group that both the OpenVPN server and Second server are set to allow all traffic from and the network ACLs are wide open.

It appears this traffic is being dropped by Amazon that originates outside the VPC, regardless of the Security Group settings.

Anything I am missing that would be causing this traffic to be dropped?

  • 1
    excellent post. can you plz share your server.conf routing settings, so others can benefit? – CMag May 30 '15 at 3:22
  • did you have to change any vpc routes? – CMag Jun 1 '15 at 3:25

Turns out EC2 was blocking the forwarded packets from the OpenVPN server.

There is a setting on the EC2 Dashboard under Network & Security -> Network Interfaces -> Actions -> Change Source/Dest. Check.

When I disabled this on all my instances traffic through the VPN is flowing as intended.

Hopefully this will help someone else.

  • 2
    I wouldn't recommend disabling the check on all instances, just the OpenVPN server is enough. As an explanation for what is going on here, see docs.aws.amazon.com/AmazonVPC/latest/UserGuide/… - "Each EC2 instance performs source/destination checks by default. This means that the instance must be the source or destination of any traffic it sends or receives". – Robert Johnson Jul 6 '15 at 15:11
  • 1
    You only have to disable source/dest check on the vpn instances, not all ec2 instances – CMag Oct 15 '15 at 3:03

You beat me to your own answer, so I'll expand on it a little...

If you need to build this into your instance bootstrap script, you can add the following to the User Data block (when starting the instance, it's under step 3, Configure Instance Details...expand the Advanced Details section at the bottom of the page) for the instance...update line 3 for correct region:

export my_instance=`curl`
export AWS_DEFAULT_REGION=us-east-1
aws ec2 modify-instance-attribute --instance-id $my_instance --no-source-dest-check

...and if it's for a NAT instance, you can modify your route table by adding this line (update route-table-id for the route table id used by your VPC):

aws ec2 replace-route --route-table-id rtb-01234567 --destination-cidr-block --instance-id $my_instance

For this to work, your instance will need rights to update the attribute and replace the route...You can make that happen with an EC2 Role with the following policy statement, then specify the policy name on the IAM Role box (also in the EC2 wizard's Step 3, Configure Instance Details):

  "Version": "2012-10-17",
  "Statement": [
      "Sid": "Stmt1413415456000",
      "Effect": "Allow",
      "Action": [
      "Resource": "*"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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