PPTP airos/ca
De Guifi.net - Wiki Català
Hem d'editar 1 arxiu, i crear-ne 4 de diferents:
vi /var/tmp/system.cfg
ppp.1.name=USUARI ppp.1.password=PASSWORD ppp.1.status=disabled ppp.status=disabled pptp.1.serverip=IP_SERVER pptp.status=enabled
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 pptp.status=enabled` if [ ! -z $pptp ] then logger -t poststart "PPTP Enabled" logger -t poststart "Configuring PPPd" user=`cat $cfg | grep ppp.1.name= |sed s/ppp.1.name=//` pass=`cat $cfg | grep ppp.1.password= |sed s/ppp.1.password=//` serverIP=`cat $cfg | grep pptp.1.serverip= |sed s/pptp.1.serverip=//` wangw=`cat $cfg | grep route.1.gateway= |sed s/route.1.gateway=//` # 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 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 del default gw $wangw 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 "Calling PPTP server" /sbin/pppd call pptp echo "$?" fi
vi /etc/persistent/ip-down
#!/bin/sh if [ -f /etc/ppp/resolv.conf ]; then if [ -f /etc/ppp/resolv.prev ]; then cp -f /etc/ppp/resolv.prev /etc/resolv.conf else rm -f /etc/resolv.conf fi fi rm -f /etc/ppp/info.$IFNAME if [ -x /bin/sysled ]; then /bin/sysled -i 0 2>/dev/null fi if [ -f /etc/ppp/rssi_decode.sh ]; then . /etc/ppp/rssi_decode.sh stop fi
vi /etc/persistent/ip-up
if [ -f /etc/ppp/resolv.conf ]; then rm -f /etc/ppp/resolv.prev if [ -f /etc/resolv.conf ]; then cp /etc/resolv.conf /etc/ppp/resolv.prev grep domain /etc/ppp/resolv.prev > /etc/resolv.conf grep search /etc/ppp/resolv.prev >> /etc/resolv.conf cat /etc/ppp/resolv.conf >> /etc/resolv.conf else cp /etc/ppp/resolv.conf /etc/. fi fi # set the txqueuelen higher than crappy 3 ifconfig $IFNAME txqueuelen 32 2>&1 > /dev/null if [ -x /bin/sysled ]; then /bin/sysled -i 1 2>/dev/null fi if [ -f /etc/ppp/rssi_decode.sh ]; then . /etc/ppp/rssi_decode.sh start fi cat > /etc/ppp/info.$IFNAME << EOF started = `cat /proc/uptime | cut -d '.' -f 1` device = $DEVICE ifname = $IFNAME name = `sed '/^name /!d; s///; s/^"//; s/"$//; q' /etc/ppp/options` iplocal = $IPLOCAL ipremote = $IPREMOTE dns1 = $DNS1 dns2 = $DNS2 peername = $PEERNAME linkname = $LINKNAME EOF
Ens queda per acabar donar permisos +x a ip-up ip-down i tunel i ja podem reiniciar. També hem de grabar la configuració des del directori
chmod +x ip-up ip-down tunel cfgmtd -w -p /etc/
Sort!