📅  最后修改于: 2023-12-03 14:38:56.084000             🧑  作者: Mango
If you want to connect to a L2TP VPN server from your Ubuntu Terminal, you can do it using the xl2tpd
package and the ppp
(Point-to-Point Protocol) daemon.
Here's how:
First, install the necessary tools:
sudo apt-get update
sudo apt-get install xl2tpd ppp
Create a file /etc/ppp/chap-secrets
with the following content:
# Secrets for authentication using CHAP
# client server secret IP addresses
your_username * your_password_here *
Replace your_username
and your_password_here
with your actual VPN username and password.
Next, create a file /etc/ppp/peers/l2tpd
with the following content:
remotename l2tpd
linkname l2tpd
require-chap
refuse-pap
refuse-eap
refuse-mschap
noauth
# Example PPP configuration for a Linux client connecting to a
# SonicWALL device running L2TP Server:
# debug
# logfile /var/log/l2tpd.log
# connect-delay 5000
# noccp
# idle 1800
# mtu 1200
# mru 1200
# file /etc/ppp/options.l2tpd
# require-mppe
ipparam l2tpd
defaultroute
replacedefaultroute
usepeerdns
# make the VPN connection automatically reconnect after connection drops
persist
If you need to specify additional options, you can create a separate file /etc/ppp/options.l2tpd
and include it in /etc/ppp/peers/l2tpd
.
Next, edit the file /etc/xl2tpd/xl2tpd.conf
and add the following lines at the end (replace vpn.example.com
with your VPN server's domain or IP address):
[iprange]
ip_range = 192.168.2.100-192.168.2.200
[lns default]
ip range = 192.168.2.1-192.168.2.99
local ip = 192.168.2.1
require chap = yes
refuse pap = yes
require authentication = yes
name = L2TPD Server
ppp debug = yes
pppoptfile = /etc/ppp/peers/l2tpd
length bit = yes
hostname = vpn.example.com
Replace 192.168.2.1
with your local IP address.
Finally, restart the services:
sudo service xl2tpd restart
sudo service pppd restart
You can now connect to the VPN by running the following command:
sudo pon l2tpd
To disconnect, run:
sudo poff l2tpd
That's it! You should now be able to connect to your L2TP VPN server using the Ubuntu Terminal.
If you encounter any issues, check the logs for errors:
tail -f /var/log/syslog | grep pppd
tail -f /var/log/syslog | grep xl2tpd