本文介绍三种Linux网络管理方式,大家根据自己情况选择合适即可。
一、传统配置
etc/network/interfaces.d
#静态:
auto eth5
iface eth5 inet static
address 192.168.100.99
netmask 255.255.255.0
auto eth0
iface eth0 inet static
address 192.168.180.1
netmask 255.255.255.0
#动态:
auto eth1
iface eth1 inet dhcp
auto eth2
iface eth2 inet dhcp
auto eth3
iface eth3 inet dhcp
auto eth4
iface eth4 inet dhcp
二、使用nmcli管理网络
nmcli是用来管理NetworkManager网络连接的命令行工具
常用命令
显示所有连接
nmcli connection show
显示连接信息
nmcli connection show connection_name
显示网络设备列表、其状态以及使用该设备的连接
nmcli device
激活连接
nmcli connection up connection_name
取消激活连接
nmcli connection down connection_name
删除连接
nmcli connection del connection_name
以太网连接:静态IP
假设进行配置以太网网卡为eth0,IP为192.168.1.10/24,默认网关为192.168.1.1,DNS服务器为202.96.128.86
为以太网连接添加新的连接
nmcli connection add con-name Example-Connection ifname eth0 type ethernet
设置 IPv4 地址
nmcli connection modify Example-Connection ipv4.addresses 192.

最低0.47元/天 解锁文章
936

被折叠的 条评论
为什么被折叠?



