Hi,
I'm trying to port forward a port from the openvpn server to a specific port on a specific client.
For example:
Openvpn server external ip: xxx.xxx.xxx.xxx
Openvpn server internal ip: 10.8.0.1
Openvpn client: 10.8.0.14
p3p1: external interface to internet
tun0: openvpn interface
i'm trying to access on the openvpn external ip on port 777 (webserver) and get redirect to 10.8.0.14:777, but i always get a timeout error or not reacheable error.
Here some informations:
iptables -L -v:
Chain INPUT (policy DROP 27 packets, 3140 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh
58 5592 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ndmp
27 1368 ACCEPT tcp -- any any anywhere anywhere tcp dpt:multiling-http
0 0 ACCEPT all -- lo any anywhere anywhere
111 48082 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:openvpn
0 0 ACCEPT tcp -- any any anywhere anywhere tcp flags:ACK/ACK
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:domain dpts:1024:65535
0 0 ACCEPT icmp -- any any anywhere anywhere icmp echo-reply
0 0 ACCEPT icmp -- any any anywhere anywhere icmp destination-unreachable
0 0 ACCEPT icmp -- any any anywhere anywhere icmp source-quench
0 0 ACCEPT icmp -- any any anywhere anywhere icmp time-exceeded
0 0 ACCEPT icmp -- any any anywhere anywhere icmp parameter-problem
0 0 ACCEPT icmp -- any any anywhere anywhere icmp echo-request
0 0 ACCEPT udp -- any any anywhere anywhere udp dpts:traceroute:33523
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
13 920 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT all -- any any 10.8.0.0/24 anywhere
0 0 REJECT all -- any any anywhere anywhere reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT 388 packets, 77762 bytes)
pkts bytes target prot opt in out source destination
iptables -L -v -t nat:
Chain PREROUTING (policy ACCEPT 51 packets, 4472 bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp -- tun0 any anywhere anywhere tcp dpt:multiling-http to:10.8.0.14:777
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- any p3p1 10.8.0.0/24 anywhere
0 0 SNAT all -- any tun0 anywhere anywhere to:93.145.96.39
36 2569 SNAT all -- any p3p1 anywhere anywhere to:10.8.0.1
Chain OUTPUT (policy ACCEPT 36 packets, 2569 bytes)
pkts bytes target prot opt in out source destination
iptables rules (i found it around in this forum, i only added a port forwarding, or i tried...):
#!/bin/sh
#
# iptables example configuration script
#
# Flush all current rules from iptables
#
iptables -F
iptables -t nat -F
iptables -t mangle -F
#
# Allow SSH connections on tcp port 22 (or whatever port you want to use)
#
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 10000 -j ACCEPT
iptables -A INPUT -p tcp --dport 777 -j ACCEPT
#
# Set default policies for INPUT, FORWARD and OUTPUT chains
#
iptables -P INPUT DROP #using DROP for INPUT is not always recommended. Change to ACCEPT if you prefer.
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
#
# Set access for localhost
#
iptables -A INPUT -i lo -j ACCEPT
#
# Accept packets belonging to established and related connections
#
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#
#Accept connections on 1194 for vpn access from clients
#Take note that the rule says "UDP", and ensure that your OpenVPN server.conf says UDP too
#
iptables -A INPUT -p udp --dport 1194 -j ACCEPT
iptables -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 777 -j DNAT --to-destination 10.8.0.14:777
iptables -t nat -A POSTROUTING -o tun0 -j SNAT --to-source xxx.xxx.xxx.xxx
iptables -t nat -A POSTROUTING -o p3p1 -j SNAT --to-source 10.8.0.1
#
#Apply forwarding for OpenVPN Tunneling
#
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT #10.8.0.0 ? Check your OpenVPN server.conf to be sure
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o p3p1 -j MASQUERADE
#
# Some generally optional rules. Enable and disable these as per your requirements
#
# Accept traffic with the ACK flag set
iptables -A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
# Accept responses to DNS queries
iptables -A INPUT -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
# Accept responses to our pings
iptables -A INPUT -p icmp -m icmp --icmp-type echo-reply -j ACCEPT
# Accept notifications of unreachable hosts
iptables -A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j ACCEPT
# Accept notifications to reduce sending speed
iptables -A INPUT -p icmp -m icmp --icmp-type source-quench -j ACCEPT
# Accept notifications of lost packets
iptables -A INPUT -p icmp -m icmp --icmp-type time-exceeded -j ACCEPT
# Accept notifications of protocol problems
iptables -A INPUT -p icmp -m icmp --icmp-type parameter-problem -j ACCEPT
# Respond to pings
iptables -A INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT
# Accept traceroutes
iptables -A INPUT -p udp -m udp --dport 33434:33523 -j ACCEPT
#
# List rules
#
iptables -L -v
Thanks in advance for every answer.