Welcome to the Linux Foundation Forum!

Route all traffic to Loopback with iptables

Hello ALL.......!

I am trying to redirect the traffic on the tun0 interface to loopback and I request you to guide me.

I have a tun0 interface and a when a client with an IP of 192.168.254.2 (coming from tun0) wants to access the Internet I do

$ iptables -A POSTROUTING -s 192.168.254.2 -t nat -o wlan0 -j MASQUERADE

and the client successfully connects to the Internet over WIFI.

Now instead of wlan0 I want to redirect all traffic coming from tun0 to Loopback on which I am running a BIND DNS server and also a lighttpd Webserver. I tried with few rules but failed to do so. Can you guide me with the right rule.

regards,

Altaf

Comments

  • Hi,

    I don't think it's possible. loopback makes sense only within Host itself. I hate to say something is impossible and I've toyed around with it for a bit, but it seems so. What you can do is tunnel/forward those ports via SSH. Or create VPN between you two(or many) and have services listening/available only via VPN.

    Regards,
    Z.

Categories

Upcoming Training