#!/bin/bash USERNAME="$1" IFACE="$2" #PPTPS=cable.netvision.net.il PPTPS=212.143.205.227 NEWDNS=194.90.1.5 PPPD_OPTIONS="" PPTP_OPTIONS="" #ifdown $IFACE #ifup $IFACE #pppd call provider $PPPD_OPTIONS pty "/usr/bin/pptp $PPTPS --nolaunchpppd $PPTP_OPTIONS #pptp $PPTPS debug name cananian remotename ntdialup 172.18.0.2:172.18.0.3 # for example only! /usr/sbin/pppoe-connect NVGW=$(ping -c 3 -w 3 $PPTPS | head -n 1 | cut -d" " -f3 | cut -d"(" -f2 | cut -d")" -f1) CABLEGW=$(route -n | grep 0.0.0.0 | cut -d" " -f10 | tail -1) route add -host $NVGW gw $CABLEGW dev $IFACE /usr/bin/pptp $NVGW debug user $USERNAME mtu 1380 mru 1380 defaultroute persist nobsdcomp usepeerdns sleep 6 NEWGW=$(ifconfig ppp0 | grep inet | cut -d":" -f3 | tail -1 | cut -d" " -f1) route add default gw $NEWGW route del default gw $CABLEGW echo nameserver $NEWDNS > /etc/resolv.conf