Start and Stop Softether from command line on linux

extute ip route show and compare route table before and after connecting to the vpn server to get all required addresses

start.sh

#!/bin/sh

[ "$UID" -eq 0 ] || exec sudo "$0" "$@"

vpnclient start
sleep 2s
vpncmd localhost /client /CMD AccountConnect [ConnectionName]
dhclient [VPN_Adapter]
ip route add [VPN_Server_IP]/32 via [Gateway_Address] dev [Network_Device_Name]
ip route del default via [Gateway_Address] dev [Network_Device_Name]
#!/bin/sh

[ "$UID" -eq 0 ] || exec sudo "$0" "$@"

vpnclient start
sleep 2s
vpncmd localhost /client /CMD AccountConnect GE
dhclient vpn_vpn
ip route add 145.245.93.56/32 via 192.168.1.1 dev wlp3s0
ip route del default via 192.168.1.1 dev wlp3s0

stop.sh

#!/bin/sh

[ "$UID" -eq 0 ] || exec sudo "$0" "$@"

vpncmd localhost /client /CMD AccountDisconnect GE
vpnclient stop
ip route del default via 192.168.30.1 dev vpn_vpn
ip route del 145.245.93.56 via 192.168.1.1 dev wlp3s0 
ip route del 192.168.30.0/24 dev vpn_vpn proto kernel scope link src
ip route add default via 192.168.1.1 dev wlp3s0 proto dhcp metric 600
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
echo 'nameserver 8.8.4.4' >> /etc/resolv.conf

References
https://pupli.net/2016/09/19/how-to-setup-softether-in-ubuntu/

Write data to text file using bash/shell scripting

You can redirect the output of a command to a file:

cat file > copy_file

or append to it

cat file >> copy_file

If you want to write directly the command is echo ‘text’

echo 'Hello World' > file

Or

# possibility 1:
echo "line 1" >> greetings.txt
echo "line 2" >> greetings.txt

# possibility 2:
echo "line 1
line 2" >> greetings.txt

# possibility 3:
cat <<EOT >> greetings.txt
line 1
line 2
EOT

 

References
https://stackoverflow.com/questions/11162406/open-and-write-data-to-text-file-using-bash-shell-scripting
https://unix.stackexchange.com/questions/77277/how-to-append-multiple-lines-to-a-file

Set Up Time Synchronization on Ubuntu with ntpd

Though timesyncd is fine for most purposes, some applications that are very sensitive to even the slightest perturbations in time may be better served by ntpd, as it uses more sophisticated techniques to constantly and gradually keep the system time on track.

sudo timedatectl set-ntp no
timedatectl
sudo apt-get install ntp
sudo ntpq -p

References

https://www.digitalocean.com/community/tutorials/how-to-set-up-time-synchronization-on-ubuntu-16-04

Extra Repositories for Ubuntu Server 18.04

/etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic universe multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic universe multiverse

deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe

deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

deb http://security.ubuntu.com/ubuntu bionic-security universe
deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

References

https://help.ubuntu.com/lts/serverguide/configuration.html.en