I want to redirect the incoming traffic to my server, in which iptables is working, to another server in LAN. However, I only want this to work if the incoming traffic is coming from a specific external IP address. Otherwise, the traffic should be dropped.
Let me put an example to clarify it:
- External client IP: 88.88.88.88
- Server IP (in same LAN): 172.26.0.99
- Destination IP (in same LAN): 172.26.0.11
Redirection example
- Client (88.88.88.88) connects to
SERVER IP (172.26.0.99)
- Traffic is tunnelled to
Destination IP (172.26.0.11)
.
Drop example
- Stranger client (66.66.66.66) tries to connect to
SERVER IP (172.26.0.99)
- Traffic is
DROPPED
If I understood correctly, you want to forward all traffic from 88.88.88.88 to the protected server 172.26.0.11. Here's an example using NAT:
Alternatively, forwarding on a per port basis, use
ipvs
or SystemD sockets oriptables -j REDIRECT
to set up the forwarding and firewall the port. Example with ipvs and iptables:it worked for me as well. Thank you for the idea.