Files
tldr/pages.zh/linux/nmcli-connection.md

33 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# nmcli 连接
> 使用 NetworkManager 管理连接。
> 此子命令也可以用 `nmcli c` 调用。
> 更多信息:<https://networkmanager.pages.freedesktop.org/NetworkManager/NetworkManager/nmcli.html>。
- 列出所有 NetworkManager 连接显示名称、UUID、类型和设备
`nmcli connection`
- 激活连接:
`nmcli connection up uuid {{uuid}}`
- 停用连接:
`nmcli connection down uuid {{uuid}}`
- 创建一个自动配置的双栈连接:
`nmcli connection add ifname {{interface_name}} type {{ethernet}} ipv4.method {{auto}} ipv6.method {{auto}}`
- 创建一个静态 IPv6 仅连接:
`nmcli connection add ifname {{interface_name}} type {{ethernet}} ip6 {{2001:db8::2/64}} gw6 {{2001:db8::1}} ipv6.dns {{2001:db8::1}} ipv4.method {{ignore}}`
- 创建一个静态 IPv4 仅连接:
`nmcli connection add ifname {{interface_name}} type {{ethernet}} ip4 {{10.0.0.7/8}} gw4 {{10.0.0.1}} ipv4.dns {{10.0.0.1}} ipv6.method {{ignore}}`
- 使用 OVPN 文件通过 OpenVPN 创建 VPN 连接:
`nmcli connection import type {{openvpn}} file {{path/to/vpn_config.ovpn}}`