Page -> Diferencia entre revisiones de «PPTP-Ubuntu» | Vistas : Página Discusión Ver fuente Historial |
De DIT-CDC
(→Instalación) |
(→Ubuntu 6.10 (Edgy Eft)) |
||
Línea 193: | Línea 193: | ||
+ | === Script dit === | ||
+ | |||
+ | <pre> | ||
+ | #!/bin/bash | ||
+ | |||
+ | usage=" | ||
+ | Conexión PPTP a la intranet del DIT | ||
+ | ----------------------------------- | ||
+ | Uso: $0 on --> Establecer túnel | ||
+ | $0 off --> Liberar túnel | ||
+ | " | ||
+ | |||
+ | if [ "$#" -ne 1 ]; then | ||
+ | echo "$usage" 1>&2 | ||
+ | exit | ||
+ | fi | ||
+ | |||
+ | TUNSRV="rpv.dit.upm.es" | ||
+ | TUNSRVIPADDR=`host $TUNSRV | grep address | awk '{printf $4}'` | ||
+ | |||
+ | establecer_tunel() | ||
+ | { | ||
+ | |||
+ | ROUTER=`ip route list | grep default | awk '{printf $3; exit}'` | ||
+ | #ROUTER=`route -n | grep "^0.0.0.0" | awk '{printf $2; exit}'` | ||
+ | IF=`ip route list | grep default | awk '{printf $5; exit}'` | ||
+ | #IF=`route -n | grep "^0.0.0.0" | awk '{printf $8; exit}'` | ||
+ | IPADDR=`ip addr show dev $IF | grep "inet " | awk '{print substr ($2, 1, length($2)-3)}'` | ||
+ | #IPADDR=`ifconfig $IF | grep "inet addr" | awk '{printf substr($2,6);exit}'` | ||
+ | echo "Connecting to DIT with PPTP (router=$ROUTER,if=$IF,ipaddr=$IPADDR)..." | ||
+ | |||
+ | cp /etc/resolv.conf /etc/resolv.conf.orig.DIT | ||
+ | |||
+ | pon DIT | ||
+ | sleep 2 | ||
+ | if [ $? -eq 0 ] | ||
+ | then | ||
+ | echo "ip route replace $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR" | ||
+ | ip route replace $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR | ||
+ | sleep 2 | ||
+ | echo "ip route replace default dev ppp0" | ||
+ | ip route replace default dev ppp0 | ||
+ | echo "done" | ||
+ | else | ||
+ | echo "error" | ||
+ | exit 1 | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | liberar_tunel() | ||
+ | { | ||
+ | |||
+ | IF=`ip route list | grep "^$TUNSRVIPADDR" | awk '{printf $5; exit}'` | ||
+ | #IF=`route -n | grep "^$TUNSRVIPADDR" | awk '{printf $8; exit}'` | ||
+ | ROUTER=`ip route list | grep "^$TUNSRVIPADDR" | awk '{printf $3; exit}'` | ||
+ | #ROUTER=`route -n | grep "^$TUNSRVIPADDR" | awk '{printf $2; exit}'` | ||
+ | IPADDR=`ip addr show dev $IF | grep "inet " | awk '{print substr ($2, 1, length($2)-3)}'` | ||
+ | #IPADDR=`ifconfig $IF | grep "inet addr" | awk '{printf substr($2,6);}'` | ||
+ | echo "Disconnecting from DIT (if=$IF,router=$ROUTER,ipaddr=$IPADDR)..." | ||
+ | |||
+ | poff DIT | ||
+ | if [ $? -eq 0 ] | ||
+ | then | ||
+ | echo "ip route del $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR" | ||
+ | ip route del $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR | ||
+ | echo "ip route replace default via $ROUTER dev $IF" | ||
+ | ip route replace default via $ROUTER dev $IF | ||
+ | mv /etc/resolv.conf.orig.DIT /etc/resolv.conf | ||
+ | echo "done" | ||
+ | else | ||
+ | exit 1 | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | # Main | ||
+ | |||
+ | case $1 in | ||
+ | |||
+ | on) | ||
+ | establecer_tunel | ||
+ | ;; | ||
+ | |||
+ | off) | ||
+ | liberar_tunel | ||
+ | ;; | ||
+ | |||
+ | *) | ||
+ | echo "$usage" 1>&2 | ||
+ | exit 1 | ||
+ | ;; | ||
+ | |||
+ | esac | ||
+ | </pre> | ||
Revisión de 16:30 1 abr 2007
Configuración de túneles PPTP en Ubuntu
Contenido
Ubuntu 6.06 (Dapper Drake)
Instalación
Procedimiento para configurar el acceso PPTP al DIT sobre un Ubuntu 6.06:
- Instalar pptp-linux
apt-get install pptp-linux
- Añadir la fuente de pptpconfig a /etc/apt/sources.list:
- Añadir el repositorio "universe" si no está disponible ya. Para ello, descomentar la línea siguiente en /etc/apt/sources.list:
- actualizar:
- instalar PPTP Client GUI:
echo -e '\n# PPTP GUI\ndeb http://quozl.netrek.org/pptp/pptpconfig ./' >> /etc/apt/sources.list
deb http://es.archive.ubuntu.com/ubuntu/ edgy universe
apt-get update
apt-get install pptpconfig
pptpconfig
Solapa Server: Name: DIT Server: rpv.dit.upm.es Domain: Username: fulanito Password: clavedefulanito
Solapa Encryption: Seleccionar "Require Microsoft Point-to-Point (MPPE)"
Establecimiento/liberación del tunel
El establecimiento y liberación del túnel se realiza desde la aplicación pptpconfig:
- Establecimiento: seleccionar la línea "DIT" en la parte superior y pinchar en la opción "Start".
- Liberación: pinchar en la opción "Stop".
También puede realizarse desde la línea de comandos mediante:
- Establecimiento:
pptpconfig DIT start
- Liberación:
pptpconfig DIT stop
Ubuntu 6.10 (Edgy Eft)
Instalación
Existe un fallo conocido en Ubuntu 6.10 debido a una incompatibilidad entre la version ppp distribuida (2.4.4) y el pptpconfig, que impide que funcionen correctamente los túneles de la misma forma que lo hacen en 6.06.
Para solucionarlo hay que:
- Bajarse una versión anterior de ppp (2.4.3) desde aquí
- Instalarla mediante:
dpkg -i ppp_2.4.3-20050321+2ubuntu1.1_i386.deb
A partir de aquí en procedimiento es:
- Instalar pptp-linux
apt-get install pptp-linux
- Añadir la fuente de pptpconfig a /etc/apt/sources.list:
- actualizar:
- instalar PPTP Client GUI:
echo -e '\n# PPTP GUI\ndeb http://quozl.netrek.org/pptp/pptpconfig ./' >> /etc/apt/sources.list
apt-get update
apt-get install pptpconfig
> pptpconfig
Solapa Server: Name: DIT Server: rpv.dit.upm.es Domain: Username: fulanito Password: clavedefulanito
Solapa Encryption: Seleccionar "Require Microsoft Point-to-Point (MPPE)"
- pon-dit:
#!/bin/bash TUNSRV="rpv.dit.upm.es" TUNSRVIPADDR=`host $TUNSRV | grep address | awk '{printf $4}'` ROUTER=`route -n | grep "^0.0.0.0" | awk '{printf $2; exit}'` IF=`route -n | grep "^0.0.0.0" | awk '{printf $8; exit}'` IPADDR=`ifconfig $IF | grep "inet addr" | awk '{printf substr($2,6);exit}'` echo "Connecting to DIT with PPTP (router=$ROUTER,if=$IF,ipaddr=$IPADDR)..." cp /etc/resolv.conf /etc/resolv.conf.orig.DIT pon DIT sleep 2 if [ $? -eq 0 ] then echo "ip route replace $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR" ip route replace $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR sleep 2 echo "ip route replace default dev ppp0" ip route replace default dev ppp0 echo "done" else echo "error" exit 1 fi
#!/bin/bash TUNSRV="rpv.dit.upm.es" TUNSRVIPADDR=`host $TUNSRV | grep address | awk '{printf $4}'` IF=`route -n | grep "^$TUNSRVIPADDR" | awk '{printf $8; exit}'` ROUTER=`route -n | grep "^$TUNSRVIPADDR" | awk '{printf $2; exit}'` IPADDR=`ifconfig $IF | grep "inet addr" | awk '{printf substr($2,6);}'` echo "Disconnecting from DIT (if=$IF,router=$ROUTER,ipaddr=$IPADDR)..." poff DIT if [ $? -eq 0 ] then echo "ip route del $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR" ip route del $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR echo "ip route replace default via $ROUTER dev $IF" ip route replace default via $ROUTER dev $IF mv /etc/resolv.conf.orig.DIT /etc/resolv.conf echo "done" else exit 1 fi
chmod +x pon-dit poff-dit
Establecimiento/liberación del tunel
Script dit
#!/bin/bash usage=" Conexión PPTP a la intranet del DIT ----------------------------------- Uso: $0 on --> Establecer túnel $0 off --> Liberar túnel " if [ "$#" -ne 1 ]; then echo "$usage" 1>&2 exit fi TUNSRV="rpv.dit.upm.es" TUNSRVIPADDR=`host $TUNSRV | grep address | awk '{printf $4}'` establecer_tunel() { ROUTER=`ip route list | grep default | awk '{printf $3; exit}'` #ROUTER=`route -n | grep "^0.0.0.0" | awk '{printf $2; exit}'` IF=`ip route list | grep default | awk '{printf $5; exit}'` #IF=`route -n | grep "^0.0.0.0" | awk '{printf $8; exit}'` IPADDR=`ip addr show dev $IF | grep "inet " | awk '{print substr ($2, 1, length($2)-3)}'` #IPADDR=`ifconfig $IF | grep "inet addr" | awk '{printf substr($2,6);exit}'` echo "Connecting to DIT with PPTP (router=$ROUTER,if=$IF,ipaddr=$IPADDR)..." cp /etc/resolv.conf /etc/resolv.conf.orig.DIT pon DIT sleep 2 if [ $? -eq 0 ] then echo "ip route replace $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR" ip route replace $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR sleep 2 echo "ip route replace default dev ppp0" ip route replace default dev ppp0 echo "done" else echo "error" exit 1 fi } liberar_tunel() { IF=`ip route list | grep "^$TUNSRVIPADDR" | awk '{printf $5; exit}'` #IF=`route -n | grep "^$TUNSRVIPADDR" | awk '{printf $8; exit}'` ROUTER=`ip route list | grep "^$TUNSRVIPADDR" | awk '{printf $3; exit}'` #ROUTER=`route -n | grep "^$TUNSRVIPADDR" | awk '{printf $2; exit}'` IPADDR=`ip addr show dev $IF | grep "inet " | awk '{print substr ($2, 1, length($2)-3)}'` #IPADDR=`ifconfig $IF | grep "inet addr" | awk '{printf substr($2,6);}'` echo "Disconnecting from DIT (if=$IF,router=$ROUTER,ipaddr=$IPADDR)..." poff DIT if [ $? -eq 0 ] then echo "ip route del $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR" ip route del $TUNSRVIPADDR via $ROUTER dev $IF src $IPADDR echo "ip route replace default via $ROUTER dev $IF" ip route replace default via $ROUTER dev $IF mv /etc/resolv.conf.orig.DIT /etc/resolv.conf echo "done" else exit 1 fi } # Main case $1 in on) establecer_tunel ;; off) liberar_tunel ;; *) echo "$usage" 1>&2 exit 1 ;; esac