📜 ⬆️ ⬇️

Clouds are even cheaper 2. Answer-continuation

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 experience with the community.

Content



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


To not change the PPTP server config after each power up


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 <<END2 #!/bin/sh ip=\`ifconfig eth0 | grep 'inet addr' | awk {'print \$2'} | sed s/.*://\` cat > /etc/iptables.conf <<END # Generated by iptables-save v1.4.21 on Tue Jan 27 09:27:18 2015 *filter :INPUT ACCEPT [288923:122111673] :FORWARD ACCEPT [526803:377139302] :OUTPUT ACCEPT [354423:281345292] -A FORWARD -s 10.1.0.0/24 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j TCPMSS --set-mss 1356 COMMIT # Completed on Tue Jan 27 09:27:18 2015 # Generated by iptables-save v1.4.21 on Tue Jan 27 09:27:18 2015 *nat :PREROUTING ACCEPT [15494:1053442] :INPUT ACCEPT [255:13359] :OUTPUT ACCEPT [37:2128] :POSTROUTING ACCEPT [37:2128] -A POSTROUTING -s 10.1.0.0/24 -o eth0 -j MASQUERADE COMMIT # Completed on Tue Jan 27 09:27:18 2015 END iptables-restore < /etc/iptables.conf END2 chmod +x /etc/network/if-pre-up.d/iptables /etc/network/if-pre-up.d/iptables # setting up pptpd.conf echo "option /etc/ppp/pptpd-options" > /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 the 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 works.
Do not forget to update the image!


Solving possible problems when setting up PPTP on Ubuntu


Advanced PPTP settings for Ubuntu

Ubuntu




Solving possible problems when configuring 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 do not wonder why the settings are not saved.
In the settings of the router, select "PPTP / Russia-PPTP" (all manufacturers write a little in their own way).



To avoid droplet deployment / removal manually


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

 npm install node ./index.js 

This “hand-made article” will create a droplet with the specified name from the specified image, asking the region and size from the list of available regions for this image.

In the new regions, I'm sorry, you will have to transfer the image yourself. It's up to you to decide.

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

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

This script can automatically manage any droplet created from any image, there is no binding exactly to PPTP.

Source: https://habr.com/ru/post/249915/


All Articles