49.网络配置 (nmcli&nmtui)
网络配置 (nmcli&nmtui)
常用命令
[root@SZ-licwatcher ~]# nmcli device |
使用 Nmcli 配置静态以太网连接
Purpose:
- static IPv4 - 192.0.2.1 with /24 subnet mask
- static IPv6 - 2001:db8:1::1 with /64 subnet mask
- IPv4 default gateway - 192.0.2.254
- IPv6 default gateway - 2001:db8:1::fffe
- IPv4 DNS server - 192.0.2.200
- An IPv6 DNS server -
2001:db8:1::ffbb
- A DNS search domain -
example.com
Procedure:
- add new connection profile for the Ethernet connection:
# 注意ifname 需要与实际对应 |
- set IPv4/IPv6 address:
[root@SZ-licwatcher ~]# nmcli connection modify *test-connection* ipv4.addresses *192.0.2.1/24* |
- set IPv4 and IPv6 connection method to manual:
[root@SZ-licwatcher ~]# nmcli connection modify test-connection ipv4.method manual ipv6.method manual |
- set IPv4 and IPv6 default gateway:
[root@SZ-licwatcher ~]# nmcli connection modify test-connection ipv4.gateway 192.0.2.254 ipv6.gateway 2001:db8:1::fffe |
- set IPv4 and IPv6 DNS server:
[root@SZ-licwatcher ~]# nmcli con modify test-connection ipv4.dns 192.0.2.200 ipv6.dns 2001:db8:1::ffbb |
- set IPv4 and IPv6 DNS search domain:
[root@SZ-licwatcher ~]# nmcli connection modify test-connection ipv4.dns-search example.com ipv6.dns-search example.com |
- activate connection:
[root@SZ-licwatcher ~]# nmcli connection up test-connection |
- Verify
# IP address verify |
- 配置 secondary IP
# 对配置ens160 添加第二IP 192.168.3.100/24 |
Nmtui
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Laplace' Café!
评论