PPTP airos/ca: Diferència entre les revisions
De Guifi.net - Wiki Català
Al (Discussió | contribucions) m (Al ha mogut PPTP airos a PPTP airos/ca) |
|||
Línia 1: | Línia 1: | ||
(Aquest tutorial serveix per a firms standards a partir de la versió XM5.x ) | (Aquest tutorial serveix per a firms standards a partir de la versió XM5.x ) | ||
− | Hem d'editar 1 arxiu, i crear-ne | + | Hem d'editar 1 arxiu, i crear-ne 2 de diferents |
'''vi /var/tmp/system.cfg''' | '''vi /var/tmp/system.cfg''' | ||
<pre> | <pre> | ||
− | + | guifibages.usuari=USUARI | |
− | + | guifibages.password=PASSWORD | |
− | + | guifibages.status=enabled | |
− | + | guifibages.serverip=IP_SERVER | |
− | + | ||
− | + | ||
</pre> | </pre> | ||
Línia 33: | Línia 31: | ||
cfg="/tmp/system.cfg" | cfg="/tmp/system.cfg" | ||
− | pptp=`cat $cfg |grep | + | pptp=`cat $cfg |grep guifibages.status=enabled` |
if [ ! -z $pptp ] | if [ ! -z $pptp ] | ||
Línia 39: | Línia 37: | ||
logger -t poststart "PPTP Enabled" | logger -t poststart "PPTP Enabled" | ||
logger -t poststart "Configuring PPPd" | logger -t poststart "Configuring PPPd" | ||
− | user=`cat $cfg | grep | + | user=`cat $cfg | grep guifibages.usuari= |sed s/guifibages.usuari=//` |
− | pass=`cat $cfg | grep | + | pass=`cat $cfg | grep guifibages.password= |sed s/guifibages.password=//` |
− | serverIP=`cat $cfg | grep | + | serverIP=`cat $cfg | grep guifibages.serverip= |sed s/guifibages.serverip=//` |
wangw=`cat $cfg | grep route.1.gateway= |sed s/route.1.gateway=//` | wangw=`cat $cfg | grep route.1.gateway= |sed s/route.1.gateway=//` | ||
+ | |||
# echo "DEBUG: using username: $user password: $pass for $serverIP" | # echo "DEBUG: using username: $user password: $pass for $serverIP" | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | # echo "DEBUG: using username: $user password: $pass for $serverIP" | |
− | + | echo "\"$user\" * \"$pass\"" > /etc/ppp/pap-secrets | |
− | + | echo "\"$user\" * \"$pass\"" > /etc/ppp/chap-secrets | |
− | + | ||
− | + | cat << EOF > /etc/ppp/options.pptp | |
− | + | lock | |
− | + | noauth | |
− | + | nobsdcomp | |
− | + | nodeflate | |
− | + | persist | |
− | + | holdoff 5 | |
− | + | +ipv6 ipv6cp-use-ipaddr | |
+ | ipv6 , | ||
+ | EOF | ||
+ | |||
+ | mkdir -p /etc/ppp/peers 2> /dev/null | ||
+ | cat << EOF > /etc/ppp/peers/pptp | ||
+ | pty "pptp $serverIP --nolaunchpppd" | ||
+ | name $user | ||
+ | defaultroute | ||
+ | remotename PPTP | ||
+ | file /etc/ppp/options.pptp | ||
+ | ipparam pptp | ||
+ | EOF | ||
+ | |||
+ | logger -t poststart "Setting up gateway" | ||
+ | route add -host $serverIP gw $wangw | ||
+ | route add -net 10.0.0.0/8 gw $wangw | ||
+ | #cp /etc/persistent/ip* /etc/ppp/ | ||
+ | logger -t poststart "Enabling IPV6 on all interfaces" | ||
+ | sysctl -w net.ipv6.conf.all.disable_ipv6=0 | ||
+ | logger -t poststart "Calling PPTP server" | ||
+ | /sbin/pppd call pptp | ||
+ | echo "$?" | ||
+ | sleep 5 | ||
+ | /sbin/ip -6 route del default ath0 | ||
+ | /sbin/ip -6 route add default dev ppp0 | ||
+ | /sbin/ip route del default | ||
+ | /sbin/ip route add default dev ppp0 | ||
+ | fi | ||
+ | |||
</pre> | </pre> | ||
− | '''Ens queda per acabar donar permisos +x a | + | '''Ens queda per acabar donar permisos +x a tunel i ja podem reiniciar. També hem de grabar la configuració des del directori''' |
<pre> | <pre> | ||
− | chmod +x | + | chmod +x tunel |
cfgmtd -w -p /etc/ | cfgmtd -w -p /etc/ | ||
</pre> | </pre> |
Revisió de 10:35, 14 des 2014
(Aquest tutorial serveix per a firms standards a partir de la versió XM5.x )
Hem d'editar 1 arxiu, i crear-ne 2 de diferents
vi /var/tmp/system.cfg
guifibages.usuari=USUARI guifibages.password=PASSWORD guifibages.status=enabled guifibages.serverip=IP_SERVER
Un cop editat l'arxiu de configuració, grabem els canvis des de l'arrel /var/tmp/
cfgmtd -w -p /etc/
Ens dirigim a /etc/persistent/ , per executar 2 lines al arrencar l'antena. Una que aixeca el tunel, i la segona que permet accedir a internet des de l'interficie LAN, fent un MASQUERADING de la LAN
vi /etc/persistent/rc.poststart
#!/bin/sh sh /etc/persistent/tunel iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
vi /etc/persistent/tunel
#!/bin/sh cfg="/tmp/system.cfg" pptp=`cat $cfg |grep guifibages.status=enabled` if [ ! -z $pptp ] then logger -t poststart "PPTP Enabled" logger -t poststart "Configuring PPPd" user=`cat $cfg | grep guifibages.usuari= |sed s/guifibages.usuari=//` pass=`cat $cfg | grep guifibages.password= |sed s/guifibages.password=//` serverIP=`cat $cfg | grep guifibages.serverip= |sed s/guifibages.serverip=//` wangw=`cat $cfg | grep route.1.gateway= |sed s/route.1.gateway=//` # echo "DEBUG: using username: $user password: $pass for $serverIP" # echo "DEBUG: using username: $user password: $pass for $serverIP" echo "\"$user\" * \"$pass\"" > /etc/ppp/pap-secrets echo "\"$user\" * \"$pass\"" > /etc/ppp/chap-secrets cat << EOF > /etc/ppp/options.pptp lock noauth nobsdcomp nodeflate persist holdoff 5 +ipv6 ipv6cp-use-ipaddr ipv6 , EOF mkdir -p /etc/ppp/peers 2> /dev/null cat << EOF > /etc/ppp/peers/pptp pty "pptp $serverIP --nolaunchpppd" name $user defaultroute remotename PPTP file /etc/ppp/options.pptp ipparam pptp EOF logger -t poststart "Setting up gateway" route add -host $serverIP gw $wangw route add -net 10.0.0.0/8 gw $wangw #cp /etc/persistent/ip* /etc/ppp/ logger -t poststart "Enabling IPV6 on all interfaces" sysctl -w net.ipv6.conf.all.disable_ipv6=0 logger -t poststart "Calling PPTP server" /sbin/pppd call pptp echo "$?" sleep 5 /sbin/ip -6 route del default ath0 /sbin/ip -6 route add default dev ppp0 /sbin/ip route del default /sbin/ip route add default dev ppp0 fi
Ens queda per acabar donar permisos +x a tunel i ja podem reiniciar. També hem de grabar la configuració des del directori
chmod +x tunel cfgmtd -w -p /etc/
Sort!