EzDevInfo.com

pptp interview questions

Top pptp frequently asked interview questions

Android. PPTP VPN client for ICS

I try to create VPN client for ICS with VpnService, I read articles about ToyVpn and I know what I should create own PPTP tunnel but I can't fount any information about how I can create PPTP tunnel with mschapv2 authentication. After some researching I see what many applications use for creating PPTP tunnel C/C++ language. But I need do it on Java. Have you any information or references how I can do it?

p.s. Please don't suggest about OpenVpn, I know it and I used it before, but now it is not right case


Source: (StackOverflow)

Create VPN on Android programmatically

I know this has been ask before ,but most of them are 3 to 4 years ago with no definite answers.I would like to know if this is already posible as of 2015.


Source: (StackOverflow)

Advertisements

Packet Sent but cannot Received Packets

I've been editing androids toyvpn sample project for vpn and i got this one for my sample app

enter image description here

I know there is something wrong/missing with my code because when i manually set up the vpn via android settings, there are packets Receive that's why i've been searching how to receive packets and i dont know how to get this working.

here is my source code that VCL that extends VpnService

import android.app.PendingIntent;
import android.net.VpnService;
import android.os.ParcelFileDescriptor;
import android.util.Log;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;

/**
 * Created by Jameshwart Lopez on 8/18/15.
 */
public class VCL extends VpnService {

    private static final String TAG = "VpnClientLibrary";
    private Thread mThread;
    private ParcelFileDescriptor mInterface;

    private String mServerAddress;
    private String mServerPort;
    private PendingIntent mConfigureIntent;
    private String mParameters;

    //a. Configure a builder for the interface.
    Builder builder = new Builder();

    public  void vclRun(){
        try {
            //a. Configure the TUN and get the interface.
            mInterface = builder.setSession("thesessionname")
                    .addAddress("192.168.0.1",24)
                    .addDnsServer("8.8.8.8")
                    .addRoute("0.0.0.0", 0).establish();
            //b. Packets to be sent are queued in this input stream.
            FileInputStream in = new FileInputStream(mInterface.getFileDescriptor());

            //b. Packets received need to be written to this output stream.
            FileOutputStream out = new FileOutputStream(mInterface.getFileDescriptor());

            // Allocate the buffer for a single packet.
            ByteBuffer packet = ByteBuffer.allocate(32767);

            //c. The UDP channel can be used to pass/get ip package to/from server
            DatagramChannel tunnel = DatagramChannel.open();

            // Connect to the server, localhost is used for demonstration only.
            mServerAddress="";//some of the vpn ip address here
            mServerPort="1723";
            InetSocketAddress server = new InetSocketAddress(mServerAddress, Integer.parseInt(mServerPort) );
            tunnel.connect(server);

            // For simplicity, we use the same thread for both reading and
            // writing. Here we put the tunnel into non-blocking mode.
            tunnel.configureBlocking(false);


            // Authenticate and configure the virtual network interface.
            handshake(tunnel);

            //d. Protect this socket, so package send by it will not be feedback to the vpn service.
            protect(tunnel.socket());

            int timer = 0;
            //e. Use a loop to pass packets.
            while (true) {
                //get packet with in
                //put packet to tunnel
                //get packet form tunnel
                //return packet with out
                //sleep is a must

                // Assume that we did not make any progress in this iteration.
                boolean idle = true;

                // Read the outgoing packet from the input stream.
                int length = in.read(packet.array());
                if (length > 0) {
                    // Write the outgoing packet to the tunnel.
                    packet.limit(length);
                    tunnel.write(packet);
                    packet.clear();

                    // There might be more outgoing packets.
                    idle = false;

                    // If we were receiving, switch to sending.
                    if (timer < 1) {
                        timer = 1;
                    }
                }

                // Read the incoming packet from the tunnel.
                length = tunnel.read(packet);
                if (length > 0) {
                    // Ignore control messages, which start with zero.
                    if (packet.get(0) != 0) {
                        // Write the incoming packet to the output stream.
                        out.write(packet.array(), 0, length);
                    }
                    packet.clear();

                    // There might be more incoming packets.
                    idle = false;

                    // If we were sending, switch to receiving.
                    if (timer > 0) {
                        timer = 0;
                    }
                }

                // If we are idle or waiting for the network, sleep for a
                // fraction of time to avoid busy looping.
                if (idle) {
                    Thread.sleep(100);

                    // Increase the timer. This is inaccurate but good enough,
                    // since everything is operated in non-blocking mode.
                    timer += (timer > 0) ? 100 : -100;

                    // We are receiving for a long time but not sending.
                    if (timer < -15000) {
                        // Send empty control messages.
                        packet.put((byte) 0).limit(1);
                        for (int i = 0; i < 3; ++i) {
                            packet.position(0);
                            tunnel.write(packet);
                        }
                        packet.clear();

                        // Switch to sending.
                        timer = 1;
                    }

                    // We are sending for a long time but not receiving.
                    //if (timer > 20000) {
                    //    throw new IllegalStateException("Timed out");
                    //}
                }


            }
        } catch (Exception e) {
            // Catch any exception
            e.printStackTrace();
        } finally {
            try {
                if (mInterface != null) {
                    mInterface.close();
                    mInterface = null;
                }
            } catch (Exception e) {
            }
        }
    }

    private void handshake(DatagramChannel tunnel) throws Exception {
        // To build a secured tunnel, we should perform mutual authentication
        // and exchange session keys for encryption. To keep things simple in
        // this demo, we just send the shared secret in plaintext and wait
        // for the server to send the parameters.
        // Allocate the buffer for handshaking.
        ByteBuffer packet = ByteBuffer.allocate(1024);

        // Control messages always start with zero.
        String password = "";//vpn password here
        packet.put((byte) 0).put(password.getBytes()).flip();

        // Send the secret several times in case of packet loss.
        for (int i = 0; i < 3; ++i) {
            Log.e("packetsdata", packet.toString());
            packet.position(0);
            tunnel.write(packet);
        }
        packet.clear();

        // Wait for the parameters within a limited time.
        for (int i = 0; i < 50; ++i) {
            Thread.sleep(100);

            // Normally we should not receive random packets.
            int length = tunnel.read(packet);
            if (length > 0 && packet.get(0) == 0) {
                configure(new String(packet.array(), 1, length - 1).trim());
                return;
            }
        }
        //throw new IllegalStateException("Timed out");
    }
    private void configure(String parameters) throws Exception {
        // If the old interface has exactly the same parameters, use it!
        if (mInterface != null) {
            Log.i(TAG, "Using the previous interface");
            return;
        }

        // Configure a builder while parsing the parameters.
        Builder builder = new Builder();
        for (String parameter : parameters.split(" ")) {
            String[] fields = parameter.split(",");
            try {
                switch (fields[0].charAt(0)) {
                    case 'm':
                        builder.setMtu(Short.parseShort(fields[1]));
                        break;
                    case 'a':
                        builder.addAddress(fields[1], Integer.parseInt(fields[2]));
                        break;
                    case 'r':
                        builder.addRoute(fields[1], Integer.parseInt(fields[2]));
                        break;
                    case 'd':
                        builder.addDnsServer(fields[1]);
                        break;
                    case 's':
                        builder.addSearchDomain(fields[1]);
                        break;
                }
            } catch (Exception e) {
                throw new IllegalArgumentException("Bad parameter: " + parameter);
            }
        }

        // Close the old interface since the parameters have been changed.
        try {
            mInterface.close();
        } catch (Exception e) {
            // ignore
        }

        // Create a new interface using the builder and save the parameters.
        mInterface = builder.setSession(mServerAddress)
                .setConfigureIntent(mConfigureIntent)
                .establish();
        mParameters = parameters;
        Log.i(TAG, "New interface: " + parameters);
    }
}

this is how i use the class above

private Thread mThread;

    /*
    * Services interface
    * */
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        // Start a new session by creating a new thread.
        mThread = new Thread(this, "VpnRunnable");
        //start the service
        mThread.start();
        /*
         *service is left "started" and will later be restarted by the system
         * http://android-developers.blogspot.com.au/2010/02/service-api-changes-starting-with.html
         */
        return START_STICKY;
    }
    @Override
    public void onDestroy() {

        if (mThread != null) {
            mThread.interrupt();
        }
        super.onDestroy();
    }


    @Override
    public synchronized void run() {
        /*
        * to run the vpn interface call the vclRun method inside VCL class
        * */
       this.vclRun();
    }

Source: (StackOverflow)

How do you connect to vpn using node.js

I am a newbie to node.js and looking for some example code or pointers on connecting through PPTP to a private virtual ip address using VPN connection. I have a node.js server running on aws that currently uses udp to connect to a public ip address. However, this needs to be changed to tunnel into the private vpn.

I have the uid,pwd and apn for the vpn. What are the steps I would need to take to tunnel in, and then connect to the private ip?

Appreciate any tips you might have.

Thanks M


Source: (StackOverflow)

DotRas error enumerating devices - RasException (Error code 1070)

Then trying to execute the following line:

ReadOnlyCollection<RasDevice> list = RasDevice.GetDevices();

I get a very non-helpful RasException (Error code 1070).

This is also thrown when executing

RasDevice.GetDeviceByName(...);

I have ran the application as administrator.

Is there a reason why enumerating the available devices may fail?


Source: (StackOverflow)

How to run pptpd in coreos?

I'm trying to run pptpd container on a CoreOS system.
But I cannot load ppp kernel modules.
CoreOS doesn't allow me create directory.
Is it possible to install the missing modules?

# cat /etc/lsb-release
DISTRIB_ID=CoreOS
DISTRIB_RELEASE=681.2.0
DISTRIB_CODENAME="Red Dog"
DISTRIB_DESCRIPTION="CoreOS 681.2.0"

# ls /lib/modules/4.0.5/kernel/drivers/net/ppp
ls: cannot access /lib/modules/4.0.5/kernel/drivers/net/ppp: No such file or directory

# mkdir /lib/modules/4.0.5/kernel/drivers/net/ppp
mkdir: cannot create directory '/lib/modules/4.0.5/kernel/drivers/net/ppp': Read-only file system

Source: (StackOverflow)

How to set permanent mtu size for ppp0

every time I connect to my VPN, I should run

sudo ifconfig ppp0 mtu 1300

How could I make it permanent?

I'm using Ubuntu 14.04


Source: (StackOverflow)

iOS app with custom VPN connect

i want to create app which can connect to VPN using PPTP, L2TP or OpenVPN, but i cant find any information about this. Only found infortmation about using IPSec and IKEv2 in ios 8 SDK.


Source: (StackOverflow)

PPTP refusing to connect when client is windows

I have a PPTP server running and I can connect to it from linux. When I try from windows 7 (2 instances tested) it fails. Here's the syslog for such a conn:

pptpd[540]: CTRL: Client 109.xxx.158.201 control connection started
pptpd[540]: CTRL: Starting call (launching pppd, opening GRE)
pppd[541]: Plugin radius.so loaded.
pppd[541]: RADIUS plugin initialized.
pppd[541]: Plugin radattr.so loaded.
pppd[541]: RADATTR plugin initialized.
pppd[541]: pppd 2.4.5 started by root, uid 0
pppd[541]: Using interface ppp0
pppd[541]: Connect: ppp0 <--> /dev/pts/1
pptpd[540]: GRE: Bad checksum from pppd.
pppd[541]: LCP: timeout sending Config-Requests
pppd[541]: Connection terminated.
pppd[541]: Modem hangup
pppd[541]: Exit.
pptpd[540]: GRE: read(fd=6,buffer=6075a0,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs
pptpd[540]: CTRL: PTY read or GRE write failed (pty,gre)=(6,7)
pptpd[540]: CTRL: Reaping child PPP[541]
pptpd[540]: CTRL: Client 109.xxx.158.201 control connection finished

I played with the mtu and ranged it from 900 to 1500 with no success. My pptp options:

name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
nodefaultroute
lock
nobsdcomp
ms-dns 10.10.0.1
noipx
mtu 1404
mru 1404

Remember! Linux client connects so ports and protocols should be enabled.

tcpdump -i eth0 port 1723 or proto 47 shows the following gist: https://gist.github.com/ciokan/5595640 where 109.xxx.158.201 is me, the client.

No firewalls on client. Everything disabled. Im not a network admin and I can't understand jack from that tcpdump. HALP :)


Source: (StackOverflow)

Problems with SCP stalling during file copy over VPN

I have a series of files I need to copy via SCP over a VPN from a remote linux server to a virtual linux server. The files are not large(4M-500M), but the file copy sometimes stalls. It seems that the network disconnect after that, because I could't receive any reply from a ping operation. And I have to restart the network service.

The virtual linux server's os is CentOS 6.4, and I use pptp as my vpn client.

From /var/log/messages I find messages like this:

pptp[14514]: anon log[decaps_gre:pptp_gre.c:414]: buffering packet 1181 (expecting 1043, lost or reordered)
pptp[14514]: anon log[decaps_gre:pptp_gre.c:414]: buffering packet 1182 (expecting 1043, lost or reordered)
pptp[14514]: anon log[decaps_gre:pptp_gre.c:414]: buffering packet 1183 (expecting 1043, lost or reordered)
...
rsyslogd-2177: imuxsock begins to drop messages from pid 14514 due to rate-limiting
rsyslogd-2177: imuxsock lost 130 messages from pid 14514 due to rate-limiting
...
anon log[decaps_gre:pptp_gre.c:414]: buffering packet 104763 (expecting 104761, lost or reordered)
anon log[decaps_gre:pptp_gre.c:414]: buffering packet 104764 (expecting 104761, lost or reordered)
anon log[decaps_gre:pptp_gre.c:414]: buffering packet 104765 (expecting 104761, lost or reordered)
...
anon warn[decaps_gre:pptp_gre.c:426]: discarding bogus packet 105383 (expecting 104814)
anon warn[decaps_gre:pptp_gre.c:426]: discarding bogus packet 105384 (expecting 104814)
anon warn[decaps_gre:pptp_gre.c:426]: discarding bogus packet 105385 (expecting 104814)

What I have tried so far:

  • limit the speed of scp

  • modify mtu of ppp0 to 1492(according to this question)

both of them not worked.


Source: (StackOverflow)

How to initiate PPTP MSCHAP authentication in java?

I'm trying to implement a PPTP android client in java for a customer. The authentication is to be done via MSCHAP-v2 (Security not a concern at this level). My initial idea was that if I send a Start-Ctrl-Connection-Request to the server (via the default port 1723), it will reply with a Start-Ctrl-Connection-Reply followed by the 16-byte authentication challenge. I'm able to read a 156-byte Start-Ctrl-Connection-Reply as expected but there's no 16-byte challenge followed. Now it seems to me that I have to request for the challenge in some other way than sending control-connections. Any idea on how to request for the auth-challenge? Even the RFC regarding MS-CHAP does not give any clue on this. Or am I missing something?


Source: (StackOverflow)

Raspberry Pi PPTP Port Opening

I configured PPTP on my Raspberry Pi with Wheezy image following the guide given in webpage:

http://www.raspberrypihelp.net/tutorials/21-pptp-vpn-server-raspberry-pi

On completion of the configuration all worked well.

I then installed MYSQL, PHP, APACHE, & PHPMyAdmin, the install went well and all appears ok.

I used this site for guidance.

http://pimylifeup.com/raspberry-pi-mysql-phpmyadmin/

I then tried to reconnect to the PPTP running on the same unit. Verifying username and password

I now get the error message 'Connecting to 192.168.10.18 using ' The remote connection was not made because the attempted VPN tunnels failed. The VPN server might be unreachable. If this connection is attempting to use an L2TP/IPsec tunnel, the security parameters required for IPsec negotiation might not be configured properl'y

If I do a port scan of the Pi port 1723 does not appear to be open.

Could be the Mysql install has closed the PPTP port?

I have run

sudo netstat -alpn |grep :1723

and the output says

tcp        0      0 0.0.0.0:1723            0.0.0.0:*               LISTEN      2567/pptpd

Please can someone advise me of the best way to open the PPTP port? Thanks


Source: (StackOverflow)

Can I use pptp on a vmware virtual machine in the nat mode?

I installed a Ubuntu 14.10 virtual machine on Windows 8.1 using Vmware. Ubuntu has access to Internet in the NAT mode. But I can't establish a pptp connection to a remote server from Ubuntu. Is this supported?


Source: (StackOverflow)

Cannot access some websites over PPTP (VPN)

I cannot load some websites over PPTP but I can load these websites over L2TP.

For example, I cannot load http://speedtest.net over PPTP...

The MRU and MTU are the same for these two protocols : 1400.

The VPN servers are installed on my VPS.

Anyone experiencing the same issue ? Is it related to the server or to the client ?

Thank you.


Source: (StackOverflow)

Connecting to VPN programmatically with PPTP in iOS

I want to connect through vpn using pptp connection programmatically.

Is this Possible? So far I have find http://ramezanpour.net/post/2014/08/03/configure-and-manage-vpn-connections-programmatically-in-ios-8/ but here only IPSec and IKEv2 protocol supported.

So is there any solution for pptp?

Thanks .


Source: (StackOverflow)