Windows 8.1 + AWS + VPN

百度真的一时半会用不惯,再加上需要收取gmail,恰好使用亚马逊AWS服务,决定配置VPN。网上有很多教程,本文针对自已环境(Windows 8.1 + AWS + VPN)简单做下笔记,方便日后使用。

1. AWS EC2 搭建VPN

1.1 SSH

我使用的是AWS EC2 (t2.micro),Ubuntu。以下操作摘自博文《如何使用aws搭建自己的VPN服务器》:

### Step 0: SSH登录AWS EC2

### Step 1: 安装pptp service. 
sudo apt-get install pptpd

### Step 2: 编辑pptp配置文件
sudo vim /etc/pptpd.conf # 在该文件末尾添加如下代码

localip 192.168.240.1
remoteip 192.168.240.2-9

### Step 3: 使用Google Public DNS
sudo vim /etc/ppp/pptpd-options # 在pptpd-options添加或者修改如下代码

ms-dns 8.8.8.8
ms-dns 8.8.4.4

### Step 4: 设置访问VPN的用户名和密码,自行替换USERNAME和PASSWORD
echo "USERNAME pptpd PASSWORD *" | sudo tee -a /etc/ppp/chap-secrets #可重复添加

### Step 5: 重启pptpd服务
sudo /etc/init.d/pptpd restart

### Step 6: 配置数据转发
sudo vim /etc/sysctl.conf #注释以下行代码
net.ipv4.ip_forward=1 

sudo sysctl -p #重新加载

### Step 7: 网络地址转换
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

sudo vim /etc/rc.local  # 修改rc.local,在exit 0前加入下面一行
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

1.2 AWS EC2控制台

进入EC2控制台,Services –> EC2 –> Instances (左侧面板) –> Security Groups (NETWORK & SECURITY) –> 选择Group ID,点击Actions –> Edit inbound rules –> Add Rule,添加如下规则:(outbound rules不需要吧?)

# Type, Protocol,     Port Range, Source
All TCP,     TCP,     0-65535,     0.0.0.0/0 (选择anywhere)
All UDP,     UDP,     443,        0.0.0.0/0 (选择anywhere)
All IMCP,     ICMP,     0-65535,    0.0.0.0/0 (选择anywhere)

如下图所示:

image

2. Windows连接VPN

(1)建立VPN链接

Control Panel –> Network and Internet –> Network and Sharing Center –> Set up a new connection or network –> Connect to a new workplace –> Use my Internet connection (VPN),输入Internet address.

Internet address: 即为AWS EC2 Elastic IPs,如52.68.57.153

(2)VPN设置

Control Panel –> Network and Internet –> Network Connections –> 右击VPN Connection –> Properties  –> Security选项卡,设置如下:

image

3. 使用VPN

点击右下角网络图标,连接VPN Connection,输入1.1设置的用户名和密码。下图所示:

image

参考资料:
[1]博文《如何使用aws搭建自己的VPN服务器
[2]博文《Win8如何设置VPN连接

赞赏

微信赞赏支付宝赞赏

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

3 thoughts on “Windows 8.1 + AWS + VPN

  • 2016年11月21日 星期一 at 03:32下午
    Permalink

    Update:

    Uncomment the following line (取消注释)

    net.ipv4.ip_forward=1

    Reply
  • 2016年11月21日 星期一 at 02:40下午
    Permalink

    $ service pptpd status
    * /usr/sbin/pptpd is not running

    解决方法,打开/etc/init.d/pptpd,为status_of_proc添加-p参数,如下:

    status_of_proc -p “$PIDFILE” “$DAEMON” “$NAME” && exit 0 || exit $?

    Reply
  • Pingback: Set up VPN on OS X with AWS | | Spark & Shine