Connect VPN on centos linux using command line

We can setup script for connect cartier love bangle vpn from command line on centos linux. Following are couple of steps but before that, you need to install pptp and pptpsetup on linux.

Run following command with your credentials …

pptpsetup –create <vpn connection name> –server <vpn host> –username <login username> –password <login password> –encrypt

You need to implement cartier love necklace following service on linux. So we can able to stop and start vpn like …

service vpn-service start|stop|status

CHANNEL=&amp;lt;vpn connection name&amp;gt;
NAME="Vpn client"
case "$1" in
echo "Starting ${NAME}..."
check=$(ps -eo pid,ppid,user,comm,args | grep pptpgw | grep -v grep |awk '{print $1}')
if [ -f "/etc/ppp/peers/${CHANNEL}" ];then
echo "Channel ${CHANNEL} exist.."
echo "${CHANNEL} doesn't exist! Please use pptp documentation for more information"
if [ -z "$check" ];then
pppd call <a href="">bracelet replica cartier</a> ${CHANNEL} logfile ~/${CHANNEL}-vpn.log usepeerdns defaultroute
echo "$(route -n | tail -n1 | awk '{print $2}')" &amp;gt; /tmp/.${CHANNEL}-vpn.log
sleep 4 ;route del default
echo -e "log file is ~/${CHANNEL}-vpn.log"
echo "..."
echo "Done."
echo "${NAME} already running [pid = $check]"
echo "killing ${NAME}..."
kill -9 $(ps -eo pid,comm,args | grep "pppd call ${CHANNEL}" | grep -v grep |awk '{print $1}')
echo "..."
echo "Done."
echo "Please run this command if any issue - $0 net"
route add default gw $(cat /tmp/.${CHANNEL}-vpn.log)
pid_of_dailer=$(ps -eo pid,comm,args | grep "pppd call ${CHANNEL}" | grep -v grep |awk '{print $1}')
pid_of_pptp1=$(ps -eo pid,ppid,user,comm,args | grep pptpgw | grep -v grep |awk '{print $1}')
pid_of_pptp2=$(ps -eo pid,ppid,user,comm,args | grep pptpcm | grep -v grep |awk '{print $1}')
echo -e "${NAME} ~ $pid_of_dailer $pid_of_pptp1 $pid_of_pptp2"
echo "Usage: $0 {start|stop|status|net}"
exit 1
exit 0

You need add your vpn hosts IP into resolv.conf

# Generated by NetworkManager
nameserver <vpn host ip>
nameserver <vpn host ip>

Categories: Linux