What's new

Closed [release] simple openvpn panel (m4vpn)

Status
Not open for further replies.
How to install OpenVPN Server for M4VPN Panel

Requirements:
x
VPS w/ Root Access (Ubuntu 14.04)
x Server-Side Certificate & Key
x Common Sense

Note:
ctrl + x para magsave ng file sa nano

Installation:
1.
Update your System Application's
Code:
$ su
$ apt-get update
$ apt-get upgrade -y

2. Install the Required Applications
Code:
$ apt-get install openvpn squid3 mysql-client ufw nano -y

3. Packet Forwarding
Code:
$ echo 1 > /proc/sys/net/ipv4/ip_forward
$ nano /etc/sysctl.conf
(hanapin nyo yung net.ipv4.ip_forward=1 at tangalin yung #)

4. Configure Firewall
Code:
$ ufw allow ssh
$ ufw allow 443/tcp
$ ufw allow 8080/tcp
$ nano /etc/default/ufw
(hanapin nyo yung DEFAULT_FORWARD_POLICY="DROP" at palitan yung "DROP" ng "ACCEPT")
$ nano /etc/ufw/before.rules

(idagdag nyo yung openvpn rules sa loob)
#
# rules.before
#
# Rules that should be run before the ufw command line added rules. Custom
# rules should be added to one of these chains:
#   ufw-before-input
#   ufw-before-output
#   ufw-before-forward
#

# START OPENVPN RULES
# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow traffic from OpenVPN client to eth0
-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
COMMIT
# END OPENVPN RULES

# Don't delete these required lines, otherwise there will be errors
*filter

$ ufw enable

5. Add your Certificate, Key and Server Configuration
Code:
Wait nyo yung next tutorial ko pano gumawa ng isang certificate and key para sa lahat ng server)

6. Add Authentication Script for M4VPN Panel
Code:
$ mkdir /etc/openvpn/script
$ cd /etc/openvpn/script
$ nano database.sh

#!/bin/bash
HOST='2.2.2.2'
PORT='3306'
USER='USERNAME' #username ng database
PASS='PASSWORD' #password ng database
DB='m4vpn-panel'

$ nano test.sh

#!/bin/bash
. /etc/openvpn/script/database.sh
username=$1
password=$2
status=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_name FROM user WHERE user_name = '$username' AND user_pass = '$password' AND user_duration>0")
[ "$status" != '' ] && [ "$status" = "$username" ] && echo 'authentication ok' && exit 0 || echo 'authentication failed.'; exit 1

$ chmod 755 *
$ ./test.sh (username sa panel) (password sa panel) (EXAMPLE: ./test.sh admin admin)
(pag authentication ok, ibig sabihin ok na sya)
$ nano login.sh

#!/bin/bash
. /etc/openvpn/script/database.sh
status=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_name FROM user WHERE user_name = '$username' AND user_pass = '$password' AND user_duration>0")
[ "$status" != '' ] && [ "$status" = "$username" ] && echo 'authentication ok' && exit 0 || echo 'authentication failed.'; exit 1

$ chmod /etc/openvpn/*

7. Start OpenVPN Server
Code:
$ service openvpn start
$ service openvpn status (dapat running sya)
 
How to install OpenVPN Server for M4VPN Panel

Requirements:
x
VPS w/ Root Access (Ubuntu 14.04)
x Server-Side Certificate & Key
x Common Sense

Note:
ctrl + x para magsave ng file sa nano

Installation:
1.
Update your System Application's
Code:
$ su
$ apt-get update
$ apt-get upgrade -y

2. Install the Required Applications
Code:
$ apt-get install openvpn squid3 mysql-client ufw nano -y

3. Packet Forwarding
Code:
$ echo 1 > /proc/sys/net/ipv4/ip_forward
$ nano /etc/sysctl.conf
(hanapin nyo yung net.ipv4.ip_forward=1 at tangalin yung #)

4. Configure Firewall
Code:
$ ufw allow ssh
$ ufw allow 443/tcp
$ ufw allow 8080/tcp
$ nano /etc/default/ufw
(hanapin nyo yung DEFAULT_FORWARD_POLICY="DROP" at palitan yung "DROP" ng "ACCEPT")
$ nano /etc/ufw/before.rules

(idagdag nyo yung openvpn rules sa loob)
#
# rules.before
#
# Rules that should be run before the ufw command line added rules. Custom
# rules should be added to one of these chains:
#   ufw-before-input
#   ufw-before-output
#   ufw-before-forward
#

# START OPENVPN RULES
# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow traffic from OpenVPN client to eth0
-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
COMMIT
# END OPENVPN RULES

# Don't delete these required lines, otherwise there will be errors
*filter

$ ufw enable

5. Add your Certificate, Key and Server Configuration
Code:
Wait nyo yung next tutorial ko pano gumawa ng isang certificate and key para sa lahat ng server)

6. Add Authentication Script for M4VPN Panel
Code:
$ mkdir /etc/openvpn/script
$ cd /etc/openvpn/script
$ nano database.sh

#!/bin/bash
HOST='2.2.2.2'
PORT='3306'
USER='USERNAME' #username ng database
PASS='PASSWORD' #password ng database
DB='m4vpn-panel'

$ nano test.sh

#!/bin/bash
. /etc/openvpn/script/database.sh
username=$1
password=$2
status=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_name FROM user WHERE user_name = '$username' AND user_pass = '$password' AND user_duration>0")
[ "$status" != '' ] && [ "$status" = "$username" ] && echo 'authentication ok' && exit 0 || echo 'authentication failed.'; exit 1

$ chmod 755 *
$ ./test.sh (username sa panel) (password sa panel) (EXAMPLE: ./test.sh admin admin)
(pag authentication ok, ibig sabihin ok na sya)
$ nano login.sh

#!/bin/bash
. /etc/openvpn/script/database.sh
status=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_name FROM user WHERE user_name = '$username' AND user_pass = '$password' AND user_duration>0")
[ "$status" != '' ] && [ "$status" = "$username" ] && echo 'authentication ok' && exit 0 || echo 'authentication failed.'; exit 1

$ chmod /etc/openvpn/*

7. Start OpenVPN Server
Code:
$ service openvpn start
$ service openvpn status (dapat running sya)
salamat boss duduguin yata ako dito. hahaha
 
How to Generate one Certificate and Keys for all server

Note: You must generate the certificate and keys inside one of your OpenVPN Server.

1. Prepare the Generator
Code:
$ su
$ cp -r /usr/share/easy-rsa/ /etc/openvpn
$ mkdir /etc/openvpn/easy-rsa/keys
$ nano /etc/openvpn/easy-rsa/vars
(The variables below marked in red should be changed according to your preference.)
export KEY_COUNTRY="PH"
export KEY_PROVINCE="MNL"
export KEY_CITY="Manila"
export KEY_ORG="M4VPN"
export KEY_EMAIL="m4rshall@phcorner.net"
export KEY_OU="PHCorner"
(Then change export KEY_NAME value to server)
export KEY_NAME="server"

2. Generate Diffie-Hellman
Code:
$ openssl dhparam -out /etc/openvpn/dh2048.pem 2048

3. Generate the Certificate
Code:
$ ./build-ca
$ ./build-key-server server
$ ./build-key client

4. Move the Certificates and Keys to OpenVPN Directory
Code:
$ mv /etc/openvpn/easy-rsa/keys /etc/openvpn
 
How to Generate one Certificate and Keys for all server

Note: You must generate the certificate and keys inside one of your OpenVPN Server.

1. Prepare the Generator
Code:
$ su
$ cp -r /usr/share/easy-rsa/ /etc/openvpn
$ mkdir /etc/openvpn/easy-rsa/keys
$ nano /etc/openvpn/easy-rsa/vars
(The variables below marked in red should be changed according to your preference.)
export KEY_COUNTRY="PH"
export KEY_PROVINCE="MNL"
export KEY_CITY="Manila"
export KEY_ORG="M4VPN"
export KEY_EMAIL="m4rshall@phcorner.net"
export KEY_OU="PHCorner"
(Then change export KEY_NAME value to server)
export KEY_NAME="server"

2. Generate Diffie-Hellman
Code:
$ openssl dhparam -out /etc/openvpn/dh2048.pem 2048

3. Generate the Certificate
Code:
$ ./build-ca
$ ./build-key-server server
$ ./build-key client

4. Move the Certificates and Keys to OpenVPN Directory
Code:
$ mv /etc/openvpn/easy-rsa/keys /etc/openvpn
Boss pasensya na. Baguhan lang po.. Anu po ba ito Cp or pc
 
boss may ksma nabang access sa database yan?ung invisible database kaya ba i access anung ittype?and anung database gamit mo hehe peace... sorry na di nako mag OCS haha
 
Status
Not open for further replies.
Back
Top