Skip to content

Traffic_Forwarding

Ebrahim Shafiei edited this page Jan 25, 2026 · 3 revisions

🔀 Complete Traffic Forwarding Guide from an Iranian Server to 4iProto Server

masquerade

This guide explains how to use IP Forwarding and iptables NAT to redirect all incoming traffic from a Linux server to a 4iProto destination server. This scenario is used for Full Traffic Forwarding, Transparent Proxy, and Gateway Relay.

Prerequisites

  • Linux operating system
  • Root access
  • iptables installed and active
  • Valid 4iProto server IP
  • Basic understanding of NAT, DNAT, SNAT, Routing

Step 1: Enable IP Forwarding

echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p

Step 2: Redirect SSH Port to Another Server

iptables -t nat -A PREROUTING -p tcp --dport 22 -j DNAT --to-destination IRAN_IP

Step 3: Forward All Traffic to 4iProto Server

iptables -t nat -A PREROUTING -j DNAT --to-destination 4iProto_IP

Step 4: Enable Source NAT

iptables -t nat -A POSTROUTING -j MASQUERADE

Important Notes

  • The SSH port rule must be applied before the general PREROUTING rule
  • Ensure alternative SSH access before applying rules
  • Adjust firewall settings if using firewalld or ufw

Clone this wiki locally