Skip to main content

RaspberryPi VPN Client

sudo apt-get install pptp-linux -y

hyunsu@zero2:~ $ sudo apt-get install pptp-linux -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  pptp-linux
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 51.2 kB of archives.
After this operation, 108 kB of additional disk space will be used.
Get:1 http://ftp.kaist.ac.kr/raspbian/raspbian bullseye/main armhf pptp-linux armhf 1.10.0-1 [51.2 kB]
Fetched 51.2 kB in 5s (9,683 B/s)
Selecting previously unselected package pptp-linux.
(Reading database ... 108666 files and directories currently installed.)
Preparing to unpack .../pptp-linux_1.10.0-1_armhf.deb ...
Unpacking pptp-linux (1.10.0-1) ...
Setting up pptp-linux (1.10.0-1) ...
Processing triggers for man-db (2.9.4-2) ...
hyunsu@zero2:~ $
hyunsu@zero2:~ $

iptime vpn 설정 

lte 계정을 만들고 연결한다. 

joang-vpn.png

hyunsu@zero2:~ $ sudo pptpsetup --create joang --server web.joang.com --username lte --password 비밀번호 --encrypt --start
Using interface ppp0
Connect: ppp0 <--> /dev/pts/2
CHAP authentication succeeded
MPPE 128-bit stateless compression enabled

결과 

hyunsu@zero2:~ $ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 50120  bytes 1032645911 (984.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 50120  bytes 1032645911 (984.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1496
        inet 192.168.0.254  netmask 255.255.255.255  destination 192.168.0.1
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 17  bytes 989 (989.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17  bytes 450 (450.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.23  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::bec4:4f25:e298:a23d  prefixlen 64  scopeid 0x20<link>
        ether d8:3a:dd:89:90:4e  txqueuelen 1000  (Ethernet)
        RX packets 6451585  bytes 372770121 (355.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 34853176  bytes 529084637 (504.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

hyunsu@zero2:~ $

연결 : sudo pon joang

끊기 : sudo poff joang

접속로그 확인  

  sudo pon joang debug dump logfd 2 nodetach

VPN 바꾸기 

sudo route add default dev ppp1  ppp1을 우선 라우트 한다. 

마지막으로 지속적으로 VPN접속을 확인하고 , 재부팅 시에도 일정 시간 후 실행하게 만든다. 

*/30 * * * * /root/startVPN.sh > /home/hyunsu/vpn.log

#!/bin/bash

export _SDATE=$(date +"%Y%m%d%H")

echo
echo '##### START VPN  #####'
echo

PSID=`ps -ef | grep 'pptp web.joang.com' | grep -v grep | awk '{print($2)}'`
PSIDLENG=${#PSID}

if [[ $PSIDLENG -gt 0 ]]
then
     echo "[$_SDATE] $PSIDLENG process starting !"
else
     echo "[$_SDATE] Need Start VPN"
     sudo pptpsetup --create joang --server web.joang.com --username lte --password 비밀번호 --encrypt --start
     sleep 10
     PSID=`ps -ef | grep 'pptp web.joang.com' | grep -v grep | awk '{print($2)}'`
     echo "[$_SDATE] Processes = $PSID"
     sudo route add default dev ppp1
     echo "[$_SDATE] Defalut route is ppp1"
fi


echo
echo '##### STOP VPN  #####'
echo