VPN server on the router. Auto VPN connection in Windows blocking access to the Internet except for VPN connection

A complete and detailed tutorial on how to set up a VPN server on a router, implement automatic connection to it in Windows and allow access to the Internet only through VPN.



The article is written in sufficient detail, even with the expectation of those people who first entered the Windows "Network Connections" section.



What this can be useful for:



  • You are a freelancer on sites like freelancer.com, upwork.com, etc. And you travel often. There is a high probability that you will be banned when logging into your account from a different IP. This article describes one solution to this problem.
  • Another need to remotely use a specific IP.
  • Provision of your IP to anyone anywhere in the world.


Content:



  1. Setting up a VPN server on a router
  2. Connect to VPN via Windows
  3. Auto VPN connection when PC is turned on
  4. Blocking access to the Internet except VPN connection (blocking the Internet without VPN)


1. Setting up a VPN server on the router



I want to say right away that not all routers support the VPN function. I will show it using the Tenda router as an example. For others, the procedure is the same.



1. We connect to the router. We enter the local IP of the router into the address bar of the browser. In my case, it is 192.168.0.1. You can see it on a sticker on the bottom of the router, or on the Internet.



image



2. Enter your username / password. Usually the login and password are the same: admin . If not, see the instructions for your router or on the Internet.



3. Go to the "VPN / PPTP server" tab. On other routers, this may be the "VPN Server" tab right away. If nothing like this is there, chances are your router doesn't support VPN.



image



4.Turn on the PPTP server, turn on encryption. Add Username (Login) and Password to connect to this server. We save.







Configuring the VPN server on the router is now complete. Let's go to Windows settings.



2. Connect to VPN via Windows



The setup will be carried out on the example of pure Windows 7. On older versions, the procedure does not differ much.



1. Go to Control Panel \ Network and Internet \ Network and Sharing Center. Click "Setting up a new connection or network".







2. Select one by one "Connect to the workplace / No, create a new network connection / Use my Internet connection (VPN)".







3. In the next window, in the "Internet address" field, enter the IP of our VPN server. In the "Destination name" field, specify any name in English without spaces (for example, vpn-lab).

IP , , -VPN-, 2ip.ru. IP .






4. Enter the Login and Password for connecting to the VPN, which were added earlier. Click "Connect".







5. If everything was done correctly, the created VPN connection will be displayed in the list of connections. We open the properties of this connection.







6. Configure items in the tabs as shown in the figures below. Click OK.







7. We check the performance. Now, when checking the external IP (for example, via the 2ip.ru website), the IP address of the router server should be displayed, not yours.



3. Auto-connect to VPN when you turn on the PC



1. Launch the "Task Scheduler".







2. Select "Create a simple task".







3. In the "Name" field, enter any name (for example AutoVPNConncet).







4. In the "Trigger" field, select "When you enter Windows".







5. Action - "Run the program".







6. Next, in the "Program or script" field, enter "C: \ Windows \ system32 \ rasdial.exe". In the "Add arguments" field, enter "<name of the VPN connection in the list of network connections> <Login> <Password>" without quotes. In my case it was "vpn-lab TestUser TestPassword".







7. Put a check mark on "Open the" Properties "window after clicking the" Finish "button". Click "Finish".







8.In the window that opens, put a tick on "Run with the highest rights". Click OK.







9. Done. It remains to check. Reboot your computer. After that, check your IP on the network (for example, at 2ip.ru). It must match the VPN address.



4. Blocking access to the Internet except VPN connection (blocking the Internet without VPN)



1. Go to Control Panel \ Network and Internet \ Network and Sharing Center.







2. The VPN connection is defined as "Home network", the network connection as "Public network".







3. Open "Windows Firewall with Advanced Security" and click on "Windows Firewall Properties".







4. In the "General profile" tab, block incoming and outgoing connections. In "Protected network connections" select all.







5. Go to the "Rules for incoming connections" tab. Click "Create Rule".







6. Next, select:



  • Rule type: "Custom"
  • Program: "All Programs"
  • Protocol and ports: "Protocol type: Any"
  • Scope: "Local IPs: Any; Remote IP: Specified IP "and here add the IP of your VPN (as in the screenshot below).
  • Action: "Allow the connection"
  • Profile: ONLY "Public"
  • Name: (any) "VPN1"


Click "Finish".







7. Go to the "Rules for outgoing connections" tab. Click "Create Rule" and do everything as in the previous paragraph.



8. We check the performance. Now, with the VPN disabled, there should be no Internet access.







I would be grateful to everyone for constructive comments and suggestions.



All Articles