So I've set up an OpenVPN server on a VPS.
All is working, but I'd like to know how to set it up that the openvpn server will allow all traffic coming into the server to be routed through the tunnel. Obviously, there are 2 ports I don't want routed through the tunnel, the openvpn connection port (65535) and port for ssh (we'll say it's port 22 for now).
ifconfig shows the following:
eth0 Link encap:Ethernet HWaddr 12:31:38:04:9E:86
inet addr:10.220.157.112 Bcast:10.220.157.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:827220 errors:0 dropped:0 overruns:0 frame:0
TX packets:262853 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1100800928 (1.0 GiB) TX bytes:98946140 (94.3 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3992 errors:0 dropped:0 overruns:0 frame:0
TX packets:3992 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:421550 (411.6 KiB) TX bytes:421550 (411.6 KiB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:54716 errors:0 dropped:0 overruns:0 frame:0
TX packets:69908 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:10905094 (10.3 MiB) TX bytes:66794107 (63.6 MiB)
and iptables -L -n shows the following:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT all -- 10.8.0.0/24 0.0.0.0/0
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
All traffic coming from the client to be passes through without a problem, but I'd also like the openvpn server to allow all tcp and udp traffic to be passed to the client with the exception of those 2 ports which are obviously not going to be passed.
TIA.
I've enclosed a diagram to show how it looks.