Mumia Paduille & others,
mp> ... iptables ... might go something like this ...
Thanks! This is my instance, not yet tested.
#=========
# Configuration of iptables at either end of an openvpn tunnel
# configured to use port 4122. Packets entering the tunnel
# are redirected to port 22, which is shared with ssh. Packets
# exiting the tunnel are redirected back to 4122.
# is 10.4.0.1 on one end and 10.4.0.2 on the other.
#
# Outgoing packets converge onto port 22.
iptables -t nat -A POSTROUTING -p tcp -s --sport 4122 -j REDIRECT --to-port 22
#
# Incoming packets diverge according to the source address.
# Packets from go to 4122. All other port 22 packets
# are undisturbed.
iptables -t nat -A PREROUTING -p tcp -s --sport 22 -j REDIRECT --to-port 4122
#=========
Does that seem reasonable?
My remaining concerns involve interactions of openvpn, tun,
ipmasq & iptables.
* Should I remove ipmasq and try to achieve LAN routing
with iptables, as explained under Routing in man openvpn?
Or is routing best left to ipmasq?
* Where does tun operate? Does it use iptables? Does it work
independently between routing and the interface?
* Will iptables recognize the tunnel address in the rules above?
I am trying to resolve some of the questions before spending
hours with trial and error. Thanks for any answers, comments
and suggestions, ... Peter E.
Desktops.OpenDoc http://carnot.yi.org/
--
Bookmark/Search this post with:
Re: openvpn, tun, ipmasq & iptables.
The problem is not that serious.
You just need to allow IP-masquerading on both the interfaces, whereas by default it only masquerades tun0.
I solved it this way in my setup:
<<< become root at command line and execute:
cd /etc/ipmasq/rules
cp A01interfaces.{def,rul}
>>>
now edit A01interfaces.rul and after these two lines:
#find interface names
EXTERNAL_OUT=$(default-if | sort -u)
add the following *extra* line
EXTERNAL_OUT="$(default-if | sort -u) $(enumerate-if | sort -u | grep ppp | grep -v "$EXTERNAL_OUT")"
This adds any ppp interfaces to the list of 'external' interfaces (ie ones that should be masqueraded), provided that they are not already in the list.
You may need to do other things dependent on your setup. The above works for me on sarge.