Linux: Mengelola Jaringan di Linux dengan NMCLI

iwanna
2 min readAug 6, 2020

--

NMCLI adalah command-line tool untuk mengendalikan NetworkManager dan melaporkan status jaringan. Ini dapat digunakan sebagai pengganti nm-applet atau klien grafis lainnya. nmcli digunakan untuk membuat, menampilkan, mengedit, menghapus, mengaktifkan, dan menonaktifkan koneksi jaringan, serta mengontrol dan menampilkan status perangkat jaringan.

How to use

Install nmcli:

sudo apt install network-manager

Start and enable network-manager:

sudo systemctl start network-manager
sudo systemctl enable network-manager

Create connection:

$ sudo nmcli connection add connection.id VPN_2 connection.type vpn connection.interface-name wlp2s0 connection.permissions spameggs vpn.service-type pptp vpn.data gateway=xxx.xxx.xxx.xxx   $ sudo nmcli connection modify VPN_2 vpn.user-name numb vpn.secrets password=xxxxxxxx

Check file config:

$ sudo cat /etc/NetworkManager/system-connections/VPN_2.nmconnection

[connection]
id=VPN_2
uuid=1342c044-108a-447c-8712-de988346fccb
type=vpn
interface-name=wlp2s0
permissions=user:spameggs:;

[vpn]
gateway=xxx.xxx.xxx.xxx
service-type=org.freedesktop.NetworkManager.pptp
user-name=numb
[vpn-secrets]
password=xxxxxxxx
[ipv4]
dns-search=
method=auto
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

Load Modules:

# for module in nf_nat_pptp nf_conntrack_pptp
> do
> modprobe $module;
> done

Configure Firewall Rules:

$ sudo firewall-cmd --permanent --add-port=1723/tcp   
$ sudo firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT
$ sudo firewall-cmd --permanent --direct --add-rule ipv6 filter INPUT 0 -p gre -j ACCEPT
$ sudo firewall-cmd --permanent --add-masquerade
$ sudo firewall-cmd --reload

Reconnect Successfully:

$ nmcli connection up VPN_2   
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)

Disconnect VPN:

$ nmcli connection down VPN_2   
Connection 'VPN_2' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

Conclusion

Untuk mengetahui lebih lanjut apa yang dapat dilakukan nmcli , jalankan perintah man nmcli dan baca halaman man, di mana Anda dapat mempelajari cara membuat, menampilkan, mengedit, menghapus, mengaktifkan, dan menonaktifkan koneksi jaringan.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

iwanna
iwanna

Written by iwanna

Software Engineer | Sharing insights on web development & coding practices.

No responses yet

Write a response