我在ubuntu 18.04上安装了pptpd,我可以使用android和windows客户端连接到vpn,但我无法访问互联网,而服务器可以完全访问互联网。在pptpd日志中,我注意到错误";不能确定代理ARP的以太网地址";。
我已经将/etc/ppp/options.ptpd中的dns更改如下:
ms-dns 8.8.8.8
ms-dns 8.8.4.4
我还在/etc/ppp/chap secret中创建了用户,客户端可以毫无问题地连接(但没有互联网接入(
我还在/etc/sysctl.conf 中启用了IP转发
net.ipv4.ip_forward = 1
并执行此命令:
sudo sysctl -p
我在/etc/pptpd.conf中更改了本地和远程IP,如下所示:
localip 10.0.0.1
remoteip 10.0.0.100-200
我也试过:
localip 192.168.0.1
remoteip 192.168.0.100-200
我为IP伪装配置了防火墙:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
这是ifconfig的结果:
photon@ubuntu1804:~$ ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 162.223.91.163 netmask 255.255.255.192 broadcast 162.223.91.191
inet6 fe80::250:56ff:fe94:32d0 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:94:32:d0 txqueuelen 1000 (Ethernet)
RX packets 543184 bytes 41817268 (41.8 MB)
RX errors 0 dropped 566 overruns 0 frame 0
TX packets 50407 bytes 6441592 (6.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 122 bytes 10010 (10.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 122 bytes 10010 (10.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
这是pptpd状态:
photon@ubuntu1804:~$ sudo systemctl status pptpd
● pptpd.service - PoPToP Point to Point Tunneling Server
Loaded: loaded (/lib/systemd/system/pptpd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2021-05-23 07:31:03 +0430; 20s ago
Docs: man:pptpd(8)
man:pptpctrl(8)
man:pptpd.conf(5)
Main PID: 6466 (pptpd)
Tasks: 3 (limit: 1107)
CGroup: /system.slice/pptpd.service
├─6466 /usr/sbin/pptpd --fg
├─6475 pptpd [5.119.181.36:478E - 0000]
└─6479 /usr/sbin/pppd local file /etc/ppp/pptpd-options 115200 10.0.0.1:10.0.0.100 ipparam 5.119.181.36 plugin /usr/lib/pptpd/pptpd-logw
May 23 07:31:12 ubuntu1804 pptpd[6475]: CTRL: Starting call (launching pppd, opening GRE)
May 23 07:31:12 ubuntu1804 pppd[6479]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
May 23 07:31:12 ubuntu1804 pppd[6479]: pppd 2.4.7 started by root, uid 0
May 23 07:31:12 ubuntu1804 pppd[6479]: Using interface ppp0
May 23 07:31:12 ubuntu1804 pppd[6479]: Connect: ppp0 <--> /dev/pts/1
May 23 07:31:13 ubuntu1804 pppd[6479]: peer from calling number 5.119.181.36 authorized
May 23 07:31:13 ubuntu1804 pppd[6479]: MPPE 128-bit stateless compression enabled
May 23 07:31:14 ubuntu1804 pppd[6479]: Cannot determine ethernet address for proxy ARP
May 23 07:31:14 ubuntu1804 pppd[6479]: local IP address 10.0.0.1
May 23 07:31:14 ubuntu1804 pppd[6479]: remote IP address 10.0.0.100
在尝试了许多解决方案后,我终于找到了答案。我的以太网接口叫ens160,所以对于IP伪装,我应该使用这个:
sudo iptables -t nat -A POSTROUTING -o ens160 -j MASQUERADE