Think before you speak, read before you think.

局域网内一台机器用做网关

虚拟机:192.168.1.111

安装 pptp-setup

yum install pptp-setup

创建 pptp

pptpsetup --create p1_jp1 --server p1.jp1.jpuyy.com --username user --password pass --start

这之后会有文件 /etc/ppp/peers/p1_jp1

# written by pptpsetup
pty "pptp p1.jp1.jpuyy.com --nolaunchpppd"
lock
noauth
nobsdcomp
nodeflate
name user
remotename p1_jp1
ipparam p1_jp1
require-mppe

对应的密码文件记录在 /etc/ppp/chap-secrets

之后要想连接或断开 pptp,可以使用,做两个软链

ln -s /usr/share/doc/ppp-2.4.5/scripts/pon /usr/local/bin/
ln -s /usr/share/doc/ppp-2.4.5/scripts/poff /usr/local/bin/

之后运行

pon p1_jp1

如果发现连不上,还需要启用 ip_gre 模块。参见这里

打开 ip 转发

更改 /etc/sysctl.conf

net.ipv4.ip_forward = 1

sysctl -p 生效

设置 nat

-A POSTROUTING -o ppp0 -j MASQUERADE

替换默认网关

ip route replace default dev ppp0

至此,局域网中的其他机器可以设置把 192.168.1.111 做为网关了。


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *