Answer the question
In order to leave comments, you need to log in
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
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.
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
in general, openvpn should work without iptables, i.e. if all policies are set to ACCEPT, then everything will rest against routing.
ip ro
help 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
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?
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question