Score:1

EC2 instance running Ubuntu as a router to Wireguard network

cn flag

I have one machine in AWS EC2 running Ubuntu 16.04 (B) with Wireguard running as a VPN server for some Road Warrior devices (C).

I'll try to sketch it below:

+-----+                              +-----+                            +-----+
|     | ---------------------------> |     | -------------------------> |     |
|  A  | 172.30.0.5/16  172.30.0.6/16 |  B  | 10.70.0.1/24  10.70.0.2/32 |  C  |
|     | ens5                    eth0 |     | wg0                    wg0 |     |
+-----+                              +-----+                            +-----+

I want to route traffic addressed to 10.70.0.0/24 from (A) to (C) via (B).

I tried following config:

On host (A):

ip route add 10.70.0.0/24 via 172.30.0.6

EC2 security group allows all trafic to and from 172.16.0.0/12.

On host (B):

sysctl -w net.ipv4.ip_forward 1
ufw allow from 172.16.0.0/12
ufw route allow out on wg0
iptables -t nat -A POSTROUTING -s 172.16.0.0/12 -o wg0 -j MASQUERADE

I've verified forwarding is enabled for all interfaces as descibed here: https://askubuntu.com/a/923292

net.ipv4.conf.eth0.forwarding = 1
net.ipv4.conf.wg0.forwarding = 1

EC2 security group allows all trafic to and from 172.16.0.0/12.


I even tried setting DEFAULT_FORWARD_POLICY="ACCEPT" in /etc/default/ufw.

I'm out of ideas what else is missing here, I can't get any packets to pass through. On host (B) iptables doesn't see any packets going through its FORWARD chain:

iptables -nv -L FORWARD
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ufw-before-logging-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 ufw-before-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 ufw-after-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 ufw-after-logging-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 ufw-reject-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 ufw-track-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0
cn flag
Make sure you disable AWS's packet [source/destination check](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_NAT_Instance.html#EIP_Disable_SrcDestCheck) for host B.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.