S
S
Sergey Blokhin2011-10-27 14:47:21
iptables
Sergey Blokhin, 2011-10-27 14:47:21

Need help with IPTABLES and transferring traffic between interfaces

There is a computer with two interfaces: etho and tun0.
It is necessary to send traffic that comes to tun0 to eth0.
To do this, the documentation for the program that creates tun0 has a recommendation for iptables.
iptables -A POSTROUTING -s 192.168.0.0/24 -t nat -o eth0 -j MASQUERADE
But doesn't work. Traffic reaches tun0, but does not get to eth0.

tun0 has address 192.168.0.0
Traffic comes to it from network 192.168.254.0/24
Address 192.168.100.101

to eth0 .0.0 to give further to 192.168.100.101?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
shadowalone, 2011-10-27
@shadowalone

1. what does it mean tun0 has the address 192.168.0.0 - this cannot be
2. check if forwarding is enabled. net.ipv4.ip_forward=1 in the /etc/sysctl.conf file
Describe clearly, otherwise you won't understand anything.

G
Gasoid, 2011-10-27
@Gasoid

openvpn
you need to enable packet forwarding as shadowalone wrote and then
iptables -A POSTROUTING -s 192.168.0.0/24 -t nat -o eth0 -j MASQUERADE

S
smartlight, 2011-10-28
@smartlight

in general, openvpn should work without iptables, i.e. if all policies are set to ACCEPT, then everything will rest against routing.
ip rohelp you.
and don't forget about: and about
# Allow TUN interface connections to OpenVPN server
$IPTABLES -A INPUT -i tun+ -j ACCEPT
# Allow TUN interface connections to be forwarded through other interfaces
$IPTABLES -A FORWARD -i tun+ -j ACCEPT

$IPTABLES -A FORWARD -s $OPENVPN_RANGE -d $LAN_RANGE -j ACCEPT
$IPTABLES -A FORWARD -s $LAN_RANGE -d $OPENVPN_RANGE -j ACCEPT

S
Sergey Blokhin, 2011-10-27
@TITnet

Partially worked after disabling rf filters.
But the problem of reverse pass of packets remained.
Traffic from tun0 now goes to eth0, but return packets are lost on eth0 and do not reach tun0.
What else can you smoke?

S
Sergey Blokhin, 2011-10-28
@TITnet

Gentlemen, thank you very much for your help.
The task was complicated by the fact that I was trying to help remotely set up a person who is far from Linux.
As a result, everything was set up and everything worked, the traffic goes in both directions as it should have been.
Thanks again everyone.

F
Fetos, 2014-08-01
@Fetos

Dear, thank you very much for your comments, very helpful. I have a question, please tell me how to configure iptables so that not the entire internal network is open, but only 1 ip address? Thank you!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question