PPTP airos/ca: Diferència entre les revisions
De Guifi.net - Wiki Català
(Hi ha 7 revisions intermèdies sense mostrar fetes per 2 usuaris) | |||
Línia 7: | Línia 7: | ||
<pre> | <pre> | ||
cat<<EOT >> /tmp/system.cfg | cat<<EOT >> /tmp/system.cfg | ||
+ | |||
guifibages.usuari=USUARI | guifibages.usuari=USUARI | ||
− | guifibages.password= | + | guifibages.password=PASSWORD |
guifibages.status=enabled | guifibages.status=enabled | ||
guifibages.serverip=IP_SERVER | guifibages.serverip=IP_SERVER | ||
Línia 22: | Línia 23: | ||
cfg="/tmp/system.cfg" | cfg="/tmp/system.cfg" | ||
− | pptp=\`cat $cfg |grep guifibages.status=enabled\` | + | pptp=\`cat \$cfg |grep guifibages.status=enabled\` |
− | if [ ! -z $pptp ] | + | if [ ! -z \$pptp ] |
then | then | ||
logger -t poststart "PPTP Enabled" | logger -t poststart "PPTP Enabled" | ||
logger -t poststart "Configuring PPPd" | logger -t poststart "Configuring PPPd" | ||
− | user=\`cat $cfg | grep guifibages.usuari= |sed s/guifibages.usuari=//\` | + | user=\`cat \$cfg | grep guifibages.usuari= |sed s/guifibages.usuari=//\` |
− | pass=\`cat $cfg | grep guifibages.password= |sed s/guifibages.password=//\` | + | pass=\`cat \$cfg | grep guifibages.password= |sed s/guifibages.password=//\` |
− | serverIP=\`cat $cfg | grep guifibages.serverip= |sed s/guifibages.serverip=//\` | + | 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 "\"$user\" * \"$pass\"" > /etc/ppp/pap-secrets | + | echo "\"\$user\" * \"\$pass\"" > /etc/ppp/pap-secrets |
− | echo "\"$user\" * \"$pass\"" > /etc/ppp/chap-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 , | ||
+ | mtu 1450 | ||
+ | mru 1450 | ||
+ | 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" | |
− | mkdir -p /etc/ppp/peers 2> /dev/null | + | route add -host \$serverIP gw \$wangw |
− | cat << EOF > /etc/ppp/peers/pptp | + | route add -net 10.0.0.0/8 gw \$wangw |
− | pty "pptp $serverIP --nolaunchpppd" | + | #cp /etc/persistent/ip* /etc/ppp/ |
− | name $user | + | logger -t poststart "Enabling IPV6 on all interfaces" |
− | defaultroute | + | sysctl -w net.ipv6.conf.all.disable_ipv6=0 |
− | remotename PPTP | + | logger -t poststart "Calling PPTP server" |
− | file /etc/ppp/options.pptp | + | /sbin/pppd call pptp |
− | ipparam pptp | + | echo "\$?" |
− | EOF | + | sleep 5 |
− | + | /sbin/ip -6 route del default ath0 | |
− | logger -t poststart "Setting up gateway" | + | /sbin/ip -6 route add default dev ppp0 |
− | route add -host $serverIP gw $wangw | + | /sbin/ip route del default |
− | route add -net 10.0.0.0/8 gw $wangw | + | /sbin/ip route add default dev ppp0 |
− | #cp /etc/persistent/ip* /etc/ppp/ | + | fi |
− | 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 | + | |
EOT | EOT | ||
Línia 78: | Línia 81: | ||
<pre> | <pre> | ||
− | cat<<EOT >> /etc/persistent/rc. | + | cat<<EOT >> /etc/persistent/rc.poststart |
#!/bin/sh | #!/bin/sh | ||
+ | echo '/sbin/ip route del default dev ath0' >>/etc/ppp/ip-up | ||
sh /etc/persistent/tunel | sh /etc/persistent/tunel | ||
− | iptables -t nat -A POSTROUTING -s 192.168. | + | iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j MASQUERADE |
EOT | EOT | ||
</pre> | </pre> | ||
Línia 88: | Línia 92: | ||
<pre> | <pre> | ||
− | chmod +x /etc/persistent/tunel | + | chmod +x /etc/persistent/tunel /etc/persistent/rc.poststart |
cfgmtd -w -p /etc/ | cfgmtd -w -p /etc/ | ||
</pre> | </pre> |
Revisió de 17:53, 1 ago 2016
(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, per fer-ho només heu de connectar-vos per ssh a l'antena utilitzant un terminal en Linux o Mac OS o bé el Putty [1] si ho feu des de Windows .
Primer de tot afegim les dades de la connexió al fitxer /tmp/system.cfg. Penseu a modificar l'USUARI, PASSWORD i IP_SERVER amb les dades de la vostra connexió.
cat<<EOT >> /tmp/system.cfg guifibages.usuari=USUARI guifibages.password=PASSWORD guifibages.status=enabled guifibages.serverip=IP_SERVER EOT
Seguidament creem un script que s'encarregarà de llegir la configuració i aixecar el túnel
cat<<EOT >>/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 "\"\$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 , mtu 1450 mru 1450 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 EOT
Finalment, afegim dues lines al fitxer /etc/persistent/rc.poststart perquè, al arrencar l'antena, aixequi el tunel, i la segona que permet accedir a internet des de l'interficie LAN, fent un MASQUERADING de la LAN
cat<<EOT >> /etc/persistent/rc.poststart #!/bin/sh echo '/sbin/ip route del default dev ath0' >>/etc/ppp/ip-up sh /etc/persistent/tunel iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j MASQUERADE EOT
Ens queda per acabar donar permisos +x a tunel i ja podem reiniciar. També hem de grabar la configuració des del directori
chmod +x /etc/persistent/tunel /etc/persistent/rc.poststart cfgmtd -w -p /etc/
Sort!