Rangkuman konfigurasi :
root@Net-DEV:~# cat /etc/NetworkManager/system-connections/vpn-mikrotik.nmconnection [connection] id=vpn-mikrotik uuid=fd71d063-220c-43a3-ad7f-dbe5c9ca53d5 type=vpn permissions= timestamp=1700089765 [vpn] gateway=203.111.29.214 ipsec-enabled=yes ipsec-psk=P@55@2020! password-flags=0 user=mydev service-type=org.freedesktop.NetworkManager.l2tp user-name=mydev [vpn-secrets] password=MyPas345#$% [ipv4] dns-search= method=auto never-default=true route1=172.29.100.0/24 [ipv6] addr-gen-mode=stable-privacy dns-search= method=disabled [proxy] root@Net-DEV:~#
Cara membuat configurasinya menggunakan command line :
nmcli c add con-name vpn-mikrotik type vpn vpn-type l2tp connection.interface-name vpn-mikrotik vpn.data 'gateway=203.111.29.214, ipsec-enabled=yes, ipsec-psk=P@55@2020!, password-flags=0' sudo nmcli connection modify vpn-mikrotik vpn.user-name mydev vpn.secrets password=DyPas345#$% cat /etc/NetworkManager/system-connections/vpn-mikrotik.nmconnection nmtui con reload
Untuk mengecek daftar koneksi
nmtui con
Untuk menyalakan koneksi vpn
root@Net-DEV:~# nmcli con up id vpn-mikrotik Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/19) root@Net-DEV:~#
Untuk menghilangkan default route
nmcli connection modify vpn-mikrotik ipv4.never-default yes
Untuk disable ipv6
nmcli connection modify vpn-mikrotik ipv6.method "disabled"
Untuk menambahkan static route
nmcli con modify vpn-mikrotik +ipv4.routes "172.29.100.0/24"
Untuk melakukan pengecekan route
## Sebelum konek ke vpn root@Net-DEV:~# ip route default via 103.150.100.254 dev eth0 proto static metric 103 103.175.218.0/23 dev eth0 proto kernel scope link src 103.175.218.204 metric 103 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 172.18.0.0/16 dev br-74f7814ea1e9 proto kernel scope link src 172.18.0.1 linkdown 172.19.0.0/16 dev br-89776c457b75 proto kernel scope link src 172.19.0.1 172.20.0.0/16 dev br-95cb43341419 proto kernel scope link src 172.20.0.1 172.21.0.0/16 dev br-66d7100abccf proto kernel scope link src 172.21.0.1 172.22.0.0/16 dev br-d26bfcd55bed proto kernel scope link src 172.22.0.1 172.23.0.0/16 dev br-7aaf6f81cf52 proto kernel scope link src 172.23.0.1 root@Net-DEV:~#
root@Net-DEV:~# ip route default via 103.150.100.254 dev eth0 proto static metric 103 103.150.100.0/23 dev eth0 proto kernel scope link src 103.175.218.204 metric 103 103.150.100.254 dev eth0 proto static scope link metric 103 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 172.18.0.0/16 dev br-74f7814ea1e9 proto kernel scope link src 172.18.0.1 linkdown 172.19.0.0/16 dev br-89776c457b75 proto kernel scope link src 172.19.0.1 172.20.0.0/16 dev br-95cb43341419 proto kernel scope link src 172.20.0.1 172.21.0.0/16 dev br-66d7100abccf proto kernel scope link src 172.21.0.1 172.22.0.0/16 dev br-d26bfcd55bed proto kernel scope link src 172.22.0.1 172.23.0.0/16 dev br-7aaf6f81cf52 proto kernel scope link src 172.23.0.1 172.29.100.0/24 dev ppp0 proto static scope link metric 50 192.168.86.1 dev ppp0 proto kernel scope link src 192.168.86.102 metric 50 203.111.29.214 via 103.175.219.254 dev eth0 proto static metric 103 root@Net-DEV:~#