Conditions are below.
- Use static IP for all outbound traffic.
- Send traffic through VPN Connection if it has the specific destination IPs.
- Send traffic through the Internet if it has NOT the specific destination IPs.
And current setup.
To use static IP for outbound traffic, I setup EC2 instance as a NAT with below configuration,
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.32.0/19 -j MASQUERADE
and configured Route Table to send all subnet traffic(0.0.0.0/0) to that EC2 instance's network interface.
But I have to use VPN if it has specific destination IP. How do I configure the network on AWS?