After you set up and log in to the VPN over the Ubuntu system you need to manually connect with different VPN servers after some duration. We can automate it using python so that automatically the IP address of our system keeps changing after some duration so that no one can have track of our system anyhow. It will make our system more protected.
Follow the steps to Automate VPN using Python:
Step 1: Open your terminal (Ctrl+Alt+T) and create a file using gedit by typing the following command on the terminal.
Step 2: import the modules of python into the opened file.
Step 3: Create a list of Free VPN server codes provided by Windscribe (VPN).
Step 4: Start a try block connect with Windscribe using os module
And, then start an infinite loop and write some lines under it.
- Choose a random code from codelist using random module.
choiceCode = random.choice(codeList)
- Create a random sleep for 15 to 20 min after which the IP of the system gets changed using time and random modules.
- Connect with the randomly chosen VPN code.
os.system("windscribe connect "+ choiceCode)
Step 5: Start a catch block and then:
- Disconnect the VPN, it will run if it gets any error.
- Display a disconnection message here.
print("sorry, some error has occured..!!")
Below is the complete code based on the above approach:
The process to execute the Automated VPN Locator Program in python:
Step 1: Log in to the Windscribe with which you have setup the VPN over the system with the command given below.
Step 2: Execute the file you have created in the above steps with the command below.
NOTE: This will change your system’s IP address randomly. Press Ctrl+c to close the VPN service.
Click here to view a small video for a better understanding of the setup and execution of the VPN Automation program.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.