LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-26-2018, 10:31 PM   #1
nicedreams
Member
 
Registered: Jun 2003
Location: Phoenix, AZ
Posts: 112

Rep: Reputation: 17
OpenVpn multiple clients iptables nat rules


What I would like to do is, lets say... 5 client devices auto openvpn into my cloud server (always on tech support devices at my clients). I have this part done.

I'm not an iptables network expert here and need help. Right now the server and connected clients can all access each other back and forth which is a security problem.

I'd like to setup iptables so it's like a NAT to where the server can access the clients, but the clients can't access the server or each other. I don't want them sharing internet traffic with my cloud server also in case it's making client web traffic go through my cloud for some reason (like a general vpn for secure internet browsing), but I think it's not. I just want to make sure I always have access to these device from my cloud server (ssh, file transfers of backups, viewing remote client logs, etc), but the clients don't have access to the server or each other.

The other part to this is I want to be able to client vpn myself from Windows into cloud vpn server and not be blocked from using putty to ssh into the clients. So my 10.8.0.2 (whatever my client IP is at the time) IP would be unblocked I guess is how it's done.

OpenVPN subnet is 10.8.0.1-xxx

============== /etc/openvpn/server.conf ===============
port 1194
proto udp
dev tun
sndbuf 0
rcvbuf 0
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-auth ta.key 0
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
cipher AES-256-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
crl-verify crl.pem

======================= openvpn_client.ovpn =========================
client
dev tun
proto udp
sndbuf 0
rcvbuf 0
remote 123.123.123.123 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
comp-lzo
setenv opt block-outside-dns
key-direction 1
verb 3

Last edited by nicedreams; 09-26-2018 at 10:39 PM. Reason: added configs
 
Old 09-27-2018, 03:15 PM   #2
nicedreams
Member
 
Registered: Jun 2003
Location: Phoenix, AZ
Posts: 112

Original Poster
Rep: Reputation: 17
Was able to figure out after finding about "net30" options and reading up more on networking. Posting how I got this working in case helps others.

The issue is that all client were on the same subnet and I was trying to find iptable rules to block them. I didn't know you could have OpenVpn assign clients in different subnets /30. I found if you change "topology subnet" to "topology net30" each client will be separate, but client and talk to server and no one else. I can then do iptable rules to bridge subnets together if needed (which I'm learning next).

I keep reading how net30 was an option to fix an issues with Windows, but I hope stays as an option since now I've read it's not recommended anymore. Well if I want each client on /30 subnet, then this seems the only way to go. Works just fine so far and hope it stays an option.

nano /etc/openvpn/server.conf

port 1194
proto udp
dev tun
sndbuf 0
rcvbuf 0
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-auth ta.key 0
topology net30
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
keepalive 10 120
cipher AES-256-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
crl-verify crl.pem
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
set rules for OpenVPN in iptables trieu1929 Linux - Security 1 07-03-2014 11:48 PM
iptables nat rules crspy Linux - Networking 1 05-03-2013 03:44 AM
pptp multiple clients behind iptables nat saf Linux - Networking 4 08-06-2012 02:43 PM
iptables rules to NAT or FORWARD packets between LAN clients templeton Linux - Networking 5 11-28-2010 09:00 AM
Will IPTables w/ NAT conflict w/ OpenVPN? licht Linux - Security 1 07-19-2007 08:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration