New CentOS v7x64 Server configuring static IP/Port Forwarding

This is the forum to post your config. Include diagrams, usage graphs, and all the other goodies to show off your network.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
MrLimo
OpenVpn Newbie
Posts: 6
Joined: Mon Mar 18, 2019 3:25 am

New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by MrLimo » Mon Mar 18, 2019 5:37 am

I have what amounts to a Raspberry Pi running as a canned OpenVPN Client and a commercial VPN account with a Static IP.
The reason for the static IP is that I can forward public ports back to the VPN Client.

I can run the device behind my home NAT successfully with the following config. The device basically needs a port trigger it sets up a session on a specific port but the audio returns on a range of ports (Or a router that can be configured for port triggering). Thus a VPN with a public static IP that forwards all ports back to the client works as expected.
Public TCP Port 80
Public UDP Ports 2074-2093
Public TCP Ports 15425-15427
Public UDP Ports 5198-5200
Public TCP Ports 5198-5200

If I start the VPN client on the device I can reach the device from its public IP HTTP://{staic-ip}

I have set up a new CentOS v7 64 server {Not married to CentOS} via the AS 2.6.1 For CentOS 7. 64 bits RPM. And it works with Tunnelblink/OpenVPN Client as expected!

This is a redacted version of a working client config file for my Raspberry Pi OpenVPN client from my Commerical VPN Account.
client
1
remote {SERVER-IP} 443 tcp
2
remote {SERVER-IP} 3690 tcp
3
remote {SERVER-IP} 2401 tcp
4
remote {SERVER-IP} 8443 tcp
5
key-direction 1
6
cipher AES-256-CBC
7
client
8
dev tun
9
resolv-retry infinite
10
nobind
11
persist-key
12
persist-tun
13
verb 3
14
reneg-sec 86400
15
echo vpn-ServerID account777
16
tun-mtu 1500
17
route-method exe
18
route-delay 2
19
redirect-gateway def1
20
comp-lzo adaptive
21
hand-window 30
22
<ca>
23
--STRIPPED INLINE CA CERT--
24
</ca>
25
<key>
26
--STRIPPED INLINE KEY--
27
</key>
28
<cert>
29
--STRIPPED INLINE CERT--
30
</cert>
31
<tls-auth>
32
--STRIPPED INLINE TLS-AUTH KEY--
33
</tls-auth>

This is a redacted version of a non-working config file generated by my OpenVPN Server.
server
1
cipher AES-256-CBC
2
setenv FORWARD_COMPATIBLE 1
3
client
4
server-poll-timeout 4
5
nobind
6
remote vpnhost.com 1194 udp
7
remote vpnhost.com 1194 udp
8
remote vpnhost.com 443 tcp
9
remote vpnhost.com 1194 udp
10
remote vpnhost.com 1194 udp
11
remote vpnhost.com 1194 udp
12
remote vpnhost.com 1194 udp
13
remote vpnhost.com 1194 udp
14
dev tun
15
dev-type tun
16
ns-cert-type server
17
setenv opt tls-version-min 1.0 or-highest
18
reneg-sec 604800
19
sndbuf 0
20
rcvbuf 0
21
comp-lzo no
22
verb 3
23
setenv PUSH_PEER_INFO
24
<ca>
25
--STRIPPED INLINE CA CERT--
26
</ca>
27
<cert>
28
--STRIPPED INLINE CERT--
29
</cert>
30
<key>
31
--STRIPPED INLINE KEY--
32
</key>
33
key-direction 1
34
<tls-auth>
35
--STRIPPED INLINE TLS-AUTH KEY--
36
</tls-auth>


Being that this is basically my private VPN server is there a way to configure the server/client setup that will mimic a static IP Ie. forward all or the subset of ports necessary when a specific client signs on. I will also have another client that does not need the inward port forwarding.

And what do I need to tweek in my config/server setting/web interface setting etc. etc. to get this working on my Raspberry Pi?

Greg
Last edited by ecrist on Mon Mar 18, 2019 12:54 pm, edited 1 time in total.

MrLimo
OpenVpn Newbie
Posts: 6
Joined: Mon Mar 18, 2019 3:25 am

Re: New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by MrLimo » Tue Mar 19, 2019 5:05 am

Both redacted files are actually client files. Greg.

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by TinCanTech » Tue Mar 19, 2019 2:23 pm

MrLimo wrote:
Mon Mar 18, 2019 5:37 am
Being that this is basically my private VPN server is there a way to configure the server/client setup that will mimic a static IP Ie. forward all or the subset of ports necessary when a specific client signs on
Openvpn does not do port forwarding, use your firewall -- iptables.
MrLimo wrote:
Mon Mar 18, 2019 5:37 am
what do I need to tweek in my config/server setting/web interface setting etc. etc. to get this working on my Raspberry Pi?
There are no settings in openvpn for this but you will probably need to call a script when the client connects, use your firewall -- iptables.

MrLimo
OpenVpn Newbie
Posts: 6
Joined: Mon Mar 18, 2019 3:25 am

Re: New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by MrLimo » Thu Mar 21, 2019 6:04 pm

Ok I can work on the IPtables as suggested, any guidance about how to call a script and where I might find a base script to play around with. But the profile created by AS 2.6.1 For CentOS 7. 64 bits RPM version is much more complex and the Pi Client will not even connect. I need a point in the right direction in order to create a lightweight .ovpn configuration that will even connect.

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by TinCanTech » Thu Mar 21, 2019 6:18 pm

MrLimo wrote:
Thu Mar 21, 2019 6:04 pm
the profile created by AS 2.6.1 For CentOS 7. 64 bits RPM version is much more complex and the Pi Client will not even connect
So this is an Access Server problem?

MrLimo
OpenVpn Newbie
Posts: 6
Joined: Mon Mar 18, 2019 3:25 am

Re: New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by MrLimo » Sat Mar 30, 2019 6:58 pm

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet xxx.yyy.zzz.187/24 brd xxx.yyy.zz.255 scope global eth0
valid_lft forever preferred_lft forever

DHCP Low/21 1/2 of the /20
13: as0t0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 200
inet 172.27.224.1/21 brd 172.27.231.255 scope global as0t0
valid_lft forever preferred_lft forever

DHCP High/21 1/2 or the /20
14: as0t1: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 200
inet 172.27.232.1/21 brd 172.27.239.255 scope global as0t1
valid_lft forever preferred_lft forever
Static IP Range: 172.28.0.0/19
DHCP Range: 172.27.224.0/19
Advanced VPN:
Private Routed Subnet 172.28.0.0/19

OSI Layer: 3 (routing/NAT)
Clients access private subnets using: Routing
Static IP Address Network (Optional) 172.28.0.0/19

Advanced VPN:
Private Routed Subnets (Optional) 172.28.0.0/19

[root@vpn ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 0 0 0 eth0
link-local 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.27.224.0 0.0.0.0 255.255.248.0 U 0 0 0 as0t0
172.27.232.0 0.0.0.0 255.255.248.0 U 0 0 0 as0t1
xxx.yyy.zzz.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
[root@vpn ~]#

So I have a working client configuration that has a static IP assigned from openvpnas. I can't seem to figure out how to route a couple of ports from the PUBLIC Server's IP to the private static IP. The static IP's seem not to show up in the routing table. The static IP client has internet access outbound.

I'm using CentOS 7 at the moment but not married to continuing if another distribution is preferable. Found some information about IPTables and/or Firewalld configurations. I think I'm fighitng something to do with processes tied to the NAT engine and it's binding to the public IP but I can't find the path from my StaticIP to publicIP.

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by TinCanTech » Sat Mar 30, 2019 7:10 pm

TinCanTech wrote:
Thu Mar 21, 2019 6:18 pm
MrLimo wrote:
Thu Mar 21, 2019 6:04 pm
the profile created by AS 2.6.1 For CentOS 7. 64 bits RPM version is much more complex and the Pi Client will not even connect
So this is an Access Server problem?
viewtopic.php?f=30&t=22603

MrLimo
OpenVpn Newbie
Posts: 6
Joined: Mon Mar 18, 2019 3:25 am

Re: New CentOS v7x64 Server configuring static IP/Port Forwarding

Post by MrLimo » Sun Mar 31, 2019 6:12 am

I have a working Pi Client and I believe it is fully connecting to the OpenVPN Server. I can ping and transfer data to/from the Pi Client. I did reduce the complexity of the system generated file into a simplified version. I have another VPN that has a static IP and based on that config I was able to create a working client.conf/client.ovpn.

I'm now working on trying to pass traffic directed to a small list of Ports on the public IP thru OpenVPN for delivery to the static IP of the Pi Client.

I can reach the Pi Client from OpenVPNAS & the Client can reach the server and public resources.

Server's Public IP -> Route/NAT/Forward -> Pi Client Static
Server's Public IP -> TCP Port 80 -> Pi Client Static
Server's Public IP -> UDP Ports 2074-2093 -> Pi Client Static
Server's Public IP -> TCP Ports 15425-15427 -> Pi Client Static
Server's Public IP -> UDP Ports 5198-5200 -> Pi Client Static
Server's Public IP -> TCP Ports 5198-5200 -> Pi Client Static

My connection results are as follows:
Pi Client ping it's assigned static IP
root@localhost:~# ping 172.28.28.28
PING 172.28.28.28 (172.28.28.28) 56(84) bytes of data.
64 bytes from 172.28.28.28: icmp_req=1 ttl=64 time=0.217 ms

Pi Client to my IP address reflector
root@localhost:~# curl http://ip.limo.net
<html><title>IP.Limo.Net</title><font size="18">209.182.218.187</font> "OpenVPNas Server's IP"
root@localhost:~#
-----------------------
VPN Server towards Pi Client
[root@vpn ~]# ping 172.28.28.28
PING 172.28.28.28 (172.28.28.28) 56(84) bytes of data.
64 bytes from 172.28.28.28: icmp_seq=1 ttl=64 time=270 ms
64 bytes from 172.28.28.28: icmp_seq=2 ttl=64 time=193 ms

VPN Server back to Pi Client's Static IP
root@localhost:~# curl 172.28.28.28
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
.............. Port 80 Webpage as expected ..............

I believe I have the client fully functional. But I need some guidance about routing the Public ports back towards the Pi Client.

Greg

Post Reply