Good afternoon. There is a VPS on debian somewhere on the Internet with IP IP_VPS with a single interface, and a server with an external IP IP_SERVER to which I want to redirect traffic coming to IP_VPS .

I'm trying to configure an iptables rule on a VPS like this:

 iptables -t nat -A PREROUTING -p tcp --dst IP_VPS --dport 80 -j DNAT --to-destination IP_SERVER:80 

but packets IP_SERVER not reach IP_SERVER (checked wireshark). I missed something or iptables basically does not work this way?

  • What does cat /proc/sys/net/ipv4/ip_forward give? should be 1 - Mike
  • issued 0. what does it mean? - M. Paul
  • look at /etc/sysctl.conf if there is one on your system, then you need to enable ip_forward there. If not, then somewhere in the download files write echo 1 >/proc/sys/net/ipv4/ip_forward without this, the machine will not send anywhere any packets that came to it (and were not born on it itself) - Mike
  • on /etc/sysctl.conf writes Permission denied, enabled via sudo sysctl -w net.ipv4.ip_forward=1 In general, I read that ip_forward redirects packets from one interface to another, which means they should be at least 2 and one can not do? - M. Paul
  • the same , only without a car1 . - aleksandr barakin

0