Merge pull request #60 from wernerb/master
Set custom OVPN_NATDEVICE when using --net=host to custom interface.
This commit is contained in:
		
							
								
								
									
										11
									
								
								bin/ovpn_run
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								bin/ovpn_run
									
									
									
									
									
								
							@@ -24,14 +24,17 @@ if [ -d "$OPENVPN/ccd" ]; then
 | 
			
		||||
    ARGS+=("--client-config-dir" "$OPENVPN/ccd")
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# When using --net=host, use this to specify nat device.
 | 
			
		||||
[ -z "$OVPN_NATDEVICE" ] && OVPN_NATDEVICE=eth0
 | 
			
		||||
 | 
			
		||||
# Setup NAT forwarding if requested
 | 
			
		||||
if [ "$OVPN_DEFROUTE" != "0" ] || [ "$OVPN_NAT" == "1" ] ; then
 | 
			
		||||
    iptables -t nat -C POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE || {
 | 
			
		||||
      iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE
 | 
			
		||||
    iptables -t nat -C POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE || {
 | 
			
		||||
      iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE
 | 
			
		||||
    }
 | 
			
		||||
    for i in "${OVPN_ROUTES[@]}"; do
 | 
			
		||||
        iptables -t nat -C POSTROUTING -s "$i" -o eth0 -j MASQUERADE || {
 | 
			
		||||
          iptables -t nat -A POSTROUTING -s "$i" -o eth0 -j MASQUERADE
 | 
			
		||||
        iptables -t nat -C POSTROUTING -s "$i" -o $OVPN_NATDEVICE -j MASQUERADE || {
 | 
			
		||||
          iptables -t nat -A POSTROUTING -s "$i" -o $OVPN_NATDEVICE -j MASQUERADE
 | 
			
		||||
        }
 | 
			
		||||
    done
 | 
			
		||||
fi
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user