1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Redirect and forward traffic between 2 VPS

Discussion in 'VPN' started by chncar, Jul 15, 2019.

  1. chncar

    chncar Occasional Visitor

    Joined:
    Apr 13, 2015
    Messages:
    19
    Hello,

    Pls let me know if this post should not be here.

    I am runing centos7 in both VPS A and B. They are both connected to internet

    In VPS A, I would like to redirect all TCP traffic matching IPSET AAA to VPS B.

    In VPS B, I would like to forword all TCP traffic from VPS A, to internet.

    Shall I use bellowed commands in VPS A?
    iptables -t mangle -A OUTPUT -p tcp -m set --match-set AAA dst -j DNAT --to-destination VPSB IP
    iptables -t nat -A POSTROUTING -j MASQUERADE

    And in VPS B,
    What commands shall I need to use so that the traffic from VPS A can be forwarded to internet?

    thank you!
     
  2. chncar

    chncar Occasional Visitor

    Joined:
    Apr 13, 2015
    Messages:
    19

    Fixed. Openvpn did the job.