http://www.infradead.org/openconnect/ Openconnect server (ocserv) is an SSL VPN server for administrators who require elaborate user management and control. Openconnect server provides user management interfaces and back-ends necessary in enterprise environments, as well as security features, such as isolation of connected clients, features currently not available to any existing VPN servers.
cd /etc/ocserv mkdir CA cd CA ## Root CA vim ca.tmpl cn = "boer" organization = "boer" serial = 1 expiration_days = 3650 ca signing_key cert_signing_key crl_signing_key # Root CA 密钥 certtool --generate-privkey --outfile ca-key.pem # 签发证书 certtool --generate-self-signed --load-privkey ca-key.pem --template ca.tmpl --outfile ca-cert.pem
## Server CA vim server.tmpl #cn 为服务器密码或者执行该服务器的域名 cn = "vpn.boer.xyz" organization = "boer" expiration_days = 3650 signing_key encryption_key tls_www_server # Server 密钥 certtool --generate-privkey --outfile server-key.pem # 签发证书 certtool --generate-certificate --load-privkey server-key.pem --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem --template server.tmpl --outfile server-cert.pem
*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] # START INPUT RULES # Stateful Rule - INPUT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # ACCEPT traffic from Loopback interface -A INPUT -i lo -j ACCEPT # ACCEPT SSH from LAN -A INPUT -p tcp -m tcp -i eth0 --dport 22 -j ACCEPT # ACCEPT DHCP from LAN -A INPUT -p udp -m udp -i eth1 --dport 67:68 -j ACCEPT # ACCEPT Webmin from LAN (Optional, only for Webmin users) -A INPUT -p tcp -m tcp -i eth0 --dport 10000 -j ACCEPT # ACCEPT DNS UDP From LAN -A INPUT -p udp -m udp -i eth0 --dport 53 -j ACCEPT # ACCEPT DNS TCP From LAN -A INPUT -p tcp -m tcp -i eth0 --dport 53 -j ACCEPT # ACCEPT ping from LAN -A INPUT -p icmp --icmp-type echo-request -i eth1 -j ACCEPT # ACCEPT OpenConnect TCP From WAN -A INPUT -p tcp -m tcp -i eth0 --dport 443 -j ACCEPT # ACCEPT OpenConnect UPD From WAN -A INPUT -p udp -m udp -i eth0 --dport 443 -j ACCEPT # DROP wan traffic -A INPUT -i eth0 -j DROP # LOG LAN -A INPUT -i eth1 -j LOG --log-prefix "IPTABLES-LOG-INPUT-LAN:" --log-level 4 # ACCEPT LAN traffic - Learning rule - Should be changed to DROP once custom rules are created. -A INPUT -i eth1 -j ACCEPT # LAST RULE - DROP all traffic -A INPUT -j DROP # END INPUT RULES
# START FORWARD RULES # Stateful Rule - FORWARD -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT # ACCEPT LAN to WAN -A FORWARD -s 192.168.5.0/24 -j ACCEPT # LOG Forwarded traffic -A FORWARD -j LOG --log-prefix "IPTABLES-LOG-FORWARD:" --log-level 4 # LAST RULE - ACCEPT all traffic - Should be changed to DROP once custom rules are created. -A FORWARD -j ACCEPT # END FORWARD RULES
# START OUTPUT RULES # Stateful Rule - OUTPUT -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # LOG Outgoing traffic -A OUTPUT -j LOG --log-prefix "IPTABLES-LOG-OUTPUT:" --log-level 4 # LAST RULE - ACCEPT all traffic - Should be changed to DROP once custom rules are created. -A OUTPUT -j ACCEPT # END OUTPUT RULES COMMIT