Prêt à découvrir la magie anti-censure pour se libérer de la dictature d'un sh*thole ?!
Ce tuto a pour but de vous indiquer comment monter votre propre serveur VPN (sur Ubuntu) en ligne de commande, en louant un serveur ou VPS chez un provider.
Niveau necessaire : Avoir des connaissance de base en linux (putty, cd, cat, ls ...)
Cout d'un VPS : ~3-5€ mois (30€ par an)
Disclaimer : Ce tuto ne vous apprend pas à sécuriser votre serveur, ni à être un "hacker invisible" (pas d'obfurcation, rien concernant le navigateur), il s'agit d'une installation basique.
Ameliorations possibles : Ajout d'un redirection de port pour la rivière, ajout d'un container docker qbittorent
On va supposer que vous venez de prendre un serveur ou VPS :
---------------------------------------------
---------------------------------------------
#### 0) Quand vous commandez le serveur, connectez vous avec Putty (à installer sur votre PC) : https://putty.org/
#### Dans Putty, Hostname: "5.199.199.209", Port: "22"
#### Une fois sur le serveur, changez vos password : mettre un truc solide, votre serveur est sur internet, donc vous serez attaqué en permanence
root@myserver:~# passwd
New Password:
#### 1) Mise à jour
#### Mettre à jour et installer des outils :
root@myserver:~# apt update
root@myserver:~# apt upgrade
root@myserver:~# apt install dnsutils tcpdump wireguard wireguard-tools net-tools qrencode linux-headers vim curl
#### Configuration de vim vimrc pour faciliter le C/C (sauf si vous utilisez un autre editeur de texte)
root@myserver:~# echo "set nocompatible" >> .vimrc
root@myserver:~# echo "set mouse-=a" >> .vimrc
root@myserver:~# echo "set backspace=indent,eol,start" >> .vimrc
#### 2) Prise d'info
#### Recuperation des infos necessaire pour wireguard (avant de l'installer) :
#### Notez le nom de votre interface à "ip public" (ne doit pas être une ip en 192.x.x.x, 10.x.x.x, 172.x.x.x ou 127.x.x.x)
#### Par exemple, pour moi, la ligne "inet" indique mon ipv4, c'est "ens1" :
root@myserver:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
altname enp2s1
inet 5.199.199.209/24 metric 100 brd 5.199.199.255 scope global dynamic ens1
valid_lft 862674sec preferred_lft 862674sec
#### 3) Wireguard
#### Installation de wireguard ( via https://github.com/angristan/wireguard-install)
root@myserver:~# curl -O https://raw.githubusercon[...]ster/wireguard-install.sh
root@myserver:~# chmod +x wireguard-install.sh
#### Ici on lance l'install, ça sera interactif, je vous indique par des MAJUSCULES les truc à remplir
#### Normalement, vous avez juste à changer "IPv4 or IPv6 public address:" et "Public interface:"
root@myserver:~# ./wireguard-install.sh
Welcome to the WireGuard installer!
The git repository is available at: https://github.com/angristan/wireguard-install
I need to ask you a few questions before starting the setup.
You can leave the default options and just press enter if you are ok with them.
IPv4 or IPv6 public address: 5.199.199.209 <= ICI METTRE VOTRE IP PUBLIC
Public interface: ens1 <= ICI METTRE VOTRE INTERFACE
WireGuard interface name: wg0 <= LAISSER PAR DEFAUT
Server's WireGuard IPv4: 10.66.66.1 <= LAISSER PAR DEFAUT
Server's WireGuard IPv6: fd42:42:42::1 <= LAISSER PAR DEFAUT
Server's WireGuard port [1-65535]: 51603 <= PRENDRE UN PORT ENTRE 10000-65535
First DNS resolver to use for the clients: 1.1.1.1 <= METTRE LE DNS DE CLOUUDFLARE 1.1.1.1
Second DNS resolver to use for the clients (optional): 1.0.0.1 <= METTRE LE DNS DE CLOUUDFLARE 1.0.0.1
Okay, that was all I needed. We are ready to setup your WireGuard server now.
You will be able to generate a client at the end of the installation.
Press any key to continue...
* Applying /etc/sysctl.d/98-rpi.conf ...
kernel.printk = 3 4 1 3
vm.min_free_kbytes = 16384
net.ipv4.ping_group_range = 0 2147483647
* Applying /etc/sysctl.d/99-sysctl.conf ...
* Applying /etc/sysctl.d/protect-links.conf ...
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
* Applying /etc/sysctl.d/wg.conf ...
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
* Applying /etc/sysctl.conf ...
Created symlink /etc/systemd/system/multi-user.target.wants/[emailprotected] → /lib/systemd/[emailprotected].
Tell me a name for the client.
The name must consist of alphanumeric character. It may also include an underscore or a dash.
Client name: ANTIGAFAM2023 <= ICI ON CREE NOTRE UTILISATEUR
Client's WireGuard IPv4: 10.66.66.2 <= ICI ON MET BIEN L'IP
Client's WireGuard IPv6: fd42:42:42::2 <= IDEM
#### Vous allez obtenir un QRCODE secret, il s'agit de votre config VPN !
#### Sinon vous pouvez egalement retrouver votre config dans le fichier : /root/wg0-client-ANTIGAFAM2023.conf
#### 4) Sur Mon PC
#### Je dois récupérer un client VPN, ici que j'install : https://download.wireguard.com/windows-client/
#### J'ouvre mon client sur mon PC, en bas à gauche "Ajouter le tunnel" > "Ajouter un tunnel vide" :
#### Je copie/colle sur mon PC ce que je trouve dans /root/wg0-client-ANTIGAFAM2023.conf :
# Nom : *Je nomme mon VPN*
# Clé publique : *Touche à rien*
[Interface]
PrivateKey = mG*****************************c=
Address = 10.66.66.2/32, fd42:42:42::2/128
DNS = 1.1.1.1, 1.0.0.1
[Peer]
PublicKey = uX*********************************o=
PresharedKey = 1/**********************************U=
AllowedIPs = 0.0.0.0/1, 128.0.0.0/2, 192.0.0.0/9, 192.128.0.0/11, 192.160.0.0/13, 192.168.0.0/19, 192.168.32.0/20, 192.168.48.0/21, 192.168.57.0/24, 192.168.58.0/23, 192.168.60.0/22, 192.168.64.0/18, 192.168.128.0/17, 192.169.0.0/16, 192.170.0.0/15, 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4, 224.0.0.0/3, ::/1, 8000::/1
Endpoint = 5.199.199.209:51603
#### PS : Si besoin, le calcul d'ip autorisée est assez chiant dans wireguard, du coup il y a des "wireguard calculator" sur GitHub et sur le Net : https://www.procustodibus[...]rd-allowedips-calculator/
#### 5) Je test mon VPN
#### Avant tout, je test mon IPv4 sans VPN : https://ipv4.lafibre.info/ <= "Votre IPv4 publique est y.y.y.y"
#### Je l'active dans wireguard, et je lance mon navigateur pour vérifier que mon VPN fonctionne : https://ifconfig.me <= Je dois voir mon IP VPN (dans mon cas 5.199.199.209)
---------------------------------------------
---------------------------------------------
Voilà, voilà.
Mon propos est imaginaire et fictif, il n'implique donc aucun fait ou élément réel et toute ressemblance serait fortuite