Linux.com

Home Linux Community Forums Hardware Networking Route all traffic to Loopback with iptables

Route all traffic to Loopback with iptables

Link to this post 16 Jul 13

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

Link to this post 16 Jul 13

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.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board