Clouds - even cheaper 2. Answer-continued

Having played enough with DigitalOcean, using the information in the article “Clouds are Even Cheaper” , first of all I want to thank tangro for the quality material and share my best practices with the community.

Content



So let's say we have an image and a droplet on DigitalOcean.


In order not to change the PPTP server config after each turn on


Add a script to the download that will update the IP address in the PPTP and iptables settings file.
/etc/init.d/pptpsd
#!/bin/bash
ip=`ifconfig eth0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
start() {
cat > /etc/network/if-pre-up.d/iptables < /etc/iptables.conf < /etc/pptpd.conf
		echo "logwtmp" >> /etc/pptpd.conf
		echo "localip $ip" >> /etc/pptpd.conf
		echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
		/etc/init.d/pptpd restart
}
stop() {
echo "stop"
}
status() {
echo "stat"
}
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        status)
                status
                ;;
        *)
                echo "Usage: {start|stop|restart}"
                exit 1
                ;;
esac
exit $?



Next, make the script an executable file and add it to autoload:

chmod +x /etc/init.d/pptpsd
sudo update-rc.d pptpsd defaults

There is a lot of extra code, and the method is probably not the best. But it does work.
Do not forget to update image!


Solving possible problems when setting up PPTP on Ubuntu


Advanced PPTP Settings for Ubuntu

Ubuntu




Solving possible problems when setting up PPTP on a router


Router
Delete all lines in / etc / ppp / pptpd-options except:
ms-dns 8.8.8.8
ms-dns 8.8.4.4

And update the image so you won’t be surprised why the settings are not saved.
In the router settings, select "PPTP / Russia-PPTP" (all manufacturers write a little in their own way).



In order not to deal with the manual deployment / removal of droplet


We put NodeJS and clone this repository to ourselves.
In the config.json file we write the name droplet, the name of the image and your API key (take here ).
Thereafter:

npm install
node ./index.js

This "craft" will create a droplet with the specified name from the specified image, asking the region and size from the list of regions available for this image.

Sorry, image will have to be transferred to new regions yourself. Here it is up to you to decide.

If a droplet with the same name exists, it will be deleted.

After the script removes droplet, it most likely will not write anything.
After creating droplet, the script will output the IP address of the new droplet.
Droplet will start working normally (approximately) 2 minutes after the end of the script.

This script can be automatically controlled by any droplet created from any image, there is no binding specifically to PPTP.

Also popular now: