[SOLVED]OVPN server attempted logins beef up security

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
foz111
DD-WRT Guru


Joined: 01 Oct 2017
Posts: 707
Location: Earth

PostPosted: Thu Jan 20, 2022 10:25    Post subject: [SOLVED]OVPN server attempted logins beef up security Reply with quote
Following attempted logins from an outside source that keeps trying different IP's from different countries i am looking to tighten security up a bit on a friends R7000.

trying to generate tls-auth / tls-crypt
from windows command line as per egc tutorial but getting an error any help appreciated.
Output:-
C:\Program Files\OpenVPN\bin>openvpn --genkey --secret ta.key
2022-01-20 10:11:33 WARNING: Using --genkey --secret filename is DEPRECATED. Use --genkey secret filename instead.
i tried openvpn --genkey secret ta.key this failed any ideas?
I updated to latest version of openvpn for windows with all the extras installed.

also may i ask is there any easy script/firewall to ban x amount of attempts over x amount of time would be a great addition that is not to resourceful on router.

setup: main (sky) router with 1194 forwarded to dd-wrt r44715 running ovpn server.
No other ports are open an either router to outside world.
Thanks for any input

_________________
Netgear R7800 PPPoE Main Router
Network IPV4 - Isolated Vlan's with IoT Devices. Unifi AC-Pro x 3 AP's, Router Wi-Fi Disabled. OVPN Server With Paid Commercial Wireguard Client's. Gateway Mode, DNSMasq, Static Leases & DHCP, Pi-Hole DNS & Running Unbound.

No one can build you the bridge on which you, and only you, must cross the river of life!
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12881
Location: Netherlands

PostPosted: Thu Jan 20, 2022 11:09    Post subject: Reply with quote
You can also generate from the routers CLI (telnet/Putty) with:
openvpn --genkey secret /tmp/ta.key

You can get the key with WinSCP

Although 44715 is an old build so you might need: --secret

With the latest windows client this is also working for me:
openvpn --genkey secret ta.key

P.S. consider upgrading

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Thu Jan 20, 2022 12:21    Post subject: Reply with quote
Hmm, seems to me the value of rate limiting OpenVPN when you're already using tls-auth/tls-crypt is highly questionable. Other protocols (ssh, ftp, etc.) don't have the luxury of this feature, so it makes sense to offer it on the firewall page. In the case of OpenVPN, if the packet can't be decrypted due to not having the correct static key, it's going to be dropped anyway. Perhaps rate limiting might have a slight advantage in not requiring OpenVPN itself to respond AT ALL, but only the firewall (before OpenVPN is reached). But even that seems like a minor benefit.

Personally, I keep my OpenVPN server established on an old FT (FreshTomato) router, which itself is powered by a smart wifi-enabled AC adapter, which itself is running on a separate IOT network. Now I can use my smartphone to power-up the OpenVPN server on-demand rather than running it 24/7! Nothing's more secure than having the service unavailable until and unless YOU need it.

Anyway, there are plenty of websites that show you how to "rate limit" anything you want w/ firewall rules. Just search for those terms.

http://blog.serverbuddies.com/using-iptables-to-rate-limit-incoming-connections/

Also, it would make a BIG difference if you didn't use the well-known ports for your exposed services. Using 1194 is asking for trouble. It makes it too easy for hackers to know what the port is supporting. Better to use something more obscure, like 53229 or 48911. Most hackers are NOT going to bother searching all your ports, hoping to happen upon an open one and guess the protocol. Not when there's lots of low-hanging fruit on other public IPs.

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
foz111
DD-WRT Guru


Joined: 01 Oct 2017
Posts: 707
Location: Earth

PostPosted: Thu Jan 20, 2022 13:07    Post subject: Reply with quote
generated key from router with command provided thanks egc.
i will moved the port as eibgrad has suggested and have a look at rate limit / firewalls.
i am not so good with firewall rules still trying to get my head around them.
i found this posted back in 2009 on here
Code:
iptables -I INPUT -m --state NEW -m tcp -p tcp --dport 22 -m recent --update --seconds 60 --hitcount 4 -j logdrop
iptables -I INPUT -m --state NEW -m tcp -p tcp --dport 22 -m recent --set

if i change the port & protocol would this work?

_________________
Netgear R7800 PPPoE Main Router
Network IPV4 - Isolated Vlan's with IoT Devices. Unifi AC-Pro x 3 AP's, Router Wi-Fi Disabled. OVPN Server With Paid Commercial Wireguard Client's. Gateway Mode, DNSMasq, Static Leases & DHCP, Pi-Hole DNS & Running Unbound.

No one can build you the bridge on which you, and only you, must cross the river of life!
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Thu Jan 20, 2022 18:12    Post subject: Reply with quote
Here's something a bit more flexible.

Code:
WAN_IF="$(ip route | awk '/^default/{print $NF}')"
OVPN_PROTO="$(nvram get openvpn_proto | awk '{print substr ($1,1,3)}')"
OVPN_PORT="$(nvram get openvpn_port)"
iptables -I INPUT -p $OVPN_PROTO --dport $OVPN_PORT -i $WAN_IF -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j DROP
iptables -I INPUT -p $OVPN_PROTO --dport $OVPN_PORT -i $WAN_IF -m state --state NEW -m recent --set


Didn't actually try it myself. I just used the author's example as the basis for a few changes.

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
foz111
DD-WRT Guru


Joined: 01 Oct 2017
Posts: 707
Location: Earth

PostPosted: Thu Jan 20, 2022 19:42    Post subject: Reply with quote
Wow thank you eibgrad,
to confirm, i save the top 3 lines in start up and the 2 x firewall rules as firewall?
much appreciated eibgrad
Foz

_________________
Netgear R7800 PPPoE Main Router
Network IPV4 - Isolated Vlan's with IoT Devices. Unifi AC-Pro x 3 AP's, Router Wi-Fi Disabled. OVPN Server With Paid Commercial Wireguard Client's. Gateway Mode, DNSMasq, Static Leases & DHCP, Pi-Hole DNS & Running Unbound.

No one can build you the bridge on which you, and only you, must cross the river of life!
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Thu Jan 20, 2022 19:57    Post subject: Reply with quote
foz111 wrote:
Wow thank you eibgrad,
to confirm, i save the top 3 lines in start up and the 2 x firewall rules as firewall?
much appreciated eibgrad
Foz


ALL the lines go into the firewall script.

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
foz111
DD-WRT Guru


Joined: 01 Oct 2017
Posts: 707
Location: Earth

PostPosted: Fri Jan 21, 2022 13:40    Post subject: Reply with quote
thanks i wasn't sure glad i asked.
thanks again for your time and effort in helping

_________________
Netgear R7800 PPPoE Main Router
Network IPV4 - Isolated Vlan's with IoT Devices. Unifi AC-Pro x 3 AP's, Router Wi-Fi Disabled. OVPN Server With Paid Commercial Wireguard Client's. Gateway Mode, DNSMasq, Static Leases & DHCP, Pi-Hole DNS & Running Unbound.

No one can build you the bridge on which you, and only you, must cross the river of life!
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6436
Location: UK, London, just across the river..

PostPosted: Sun Jan 23, 2022 12:50    Post subject: Reply with quote
i used this for ssh in the past
iptables -N IN_SSH
iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -j IN_SSH
iptables -A IN_SSH -m recent --name sshbf --rttl --rcheck --hitcount 3 --seconds 10 -j DROP
iptables -A IN_SSH -m recent --name sshbf --rttl --rcheck --hitcount 4 --seconds 1800 -j DROP
iptables -A IN_SSH -m recent --name sshbf --set -j ACCEPT

as well eibgrad option seems more legit...as it chooses the default WAN interface and its more specific on correct values...

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
foz111
DD-WRT Guru


Joined: 01 Oct 2017
Posts: 707
Location: Earth

PostPosted: Mon Jan 24, 2022 9:15    Post subject: Reply with quote
Just in case anyone finds this thread when using ta.key with crapple ios, i was unable to get the ios to read the ta.key file so i added it into the ovpn client using <tls-crypt> xxxx </tls-crypt> tags (also worked with Android) and hashed out/removed #tls-crypt ta.key in config.
_________________
Netgear R7800 PPPoE Main Router
Network IPV4 - Isolated Vlan's with IoT Devices. Unifi AC-Pro x 3 AP's, Router Wi-Fi Disabled. OVPN Server With Paid Commercial Wireguard Client's. Gateway Mode, DNSMasq, Static Leases & DHCP, Pi-Hole DNS & Running Unbound.

No one can build you the bridge on which you, and only you, must cross the river of life!
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum