VPN 서버 간단하게 설정하기

Ubuntu Korea Community Wiki
둘러보기로 이동 검색으로 이동

VPN서버 쉽게 설치 / 운영하기

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo apt-get install pptpd|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo apt-get install pptpd}}}}
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo vi /etc/pptpd.conf|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo vi /etc/pptpd.conf}}}}


아래 두 라인을 적거나 주석을 해제한다. localip는 해당 서버의 내부 IP주소를 적는다. 접속받을 클라이언트의 IP 주소범위 지정은 알아서.

{{#ifeq: msg|msg|localip        192.168.1.1|{{#ifeq: misc|msg|localip        192.168.1.1  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} localip        192.168.1.1 {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}
{{#ifeq: msg|msg|remoteip        192.168.1.230-235|{{#ifeq: misc|msg|remoteip        192.168.1.230-235  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} remoteip        192.168.1.230-235 {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo vi /etc/ppp/chap-secrets|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo vi /etc/ppp/chap-secrets}}}}

아래의 라인을 적는다.

{{#ifeq: msg|msg| ID       pptpd   password *|{{#ifeq: misc|msg| ID       pptpd   password *  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}}  ID       pptpd   password * {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}
{{#ifeq: msg|msg|예:    jswlinux     pptpd     weicr$3frf     *|{{#ifeq: misc|msg|예:    jswlinux     pptpd     weicr$3frf     *  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} 예:    jswlinux     pptpd     weicr$3frf     * {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}

네트워킹 설정을 변경해야한다. 방화벽에 VPN접속을 받아서 데이터를 매스커레이딩 할 수 있게 해준다.

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo vi /etc/rc.local|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo vi /etc/rc.local}}}}
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE}}}}
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo vi /etc/sysctl.conf|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo vi /etc/sysctl.conf}}}}


아래의 라인을 주석해제한다.

{{#ifeq: msg|msg|net.ipv4.ip_forward=1|{{#ifeq: misc|msg|net.ipv4.ip_forward=1  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} net.ipv4.ip_forward=1 {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}

PPTP 데몬을 재시작한다.

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo /etc/init.d/pptpd restart|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo /etc/init.d/pptpd restart}}}}

공유기에서 1723번 포트를 서버로 포워딩해준다.

일부 사이트들이 접속이 되지 않을 때에는 PMTU문제로 아래명령어를 입력해주자

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu}}}}

--Seony (토론) 2014년 4월 25일 (금) 18:37 (KST)