步骤一:挂载本地镜像
# mount /dev/sr1 /mnt
(补充:这里以挂载 /dev/sr1 到 /mnt 目录为例)
步骤二:添加本地镜里的软件源
# zypper ar file:///mnt/Module-Basesystem local
(补充:这里以将 file:///mnt/Module-Basesystem 添加到软件源并命名为 local 为例)
# mount /dev/sr1 /mnt
(补充:这里以挂载 /dev/sr1 到 /mnt 目录为例)
# zypper ar file:///mnt/Module-Basesystem local
(补充:这里以将 file:///mnt/Module-Basesystem 添加到软件源并命名为 local 为例)
ipmitool安装,常用指令
IPMI: Intelligent Platform Management Interface
1.下载地址:
https://sourceforge.net/projects/ipmitool/
2.安装步骤
a. tar -xvf ipmitool-1.8.18.tar.bz2
b. cd ipmitool-1.8.18
c. ./configure
d. make
e.make install
f.
modprobe ipmi_si
modprobe ipmi_devintf
modprobe ipmi_msghandler
安装成功(实测Centos7.4)
3.常用指令
远程电源控制类 远程电源控制类
Ipmitool -I lanplus –H 10.32.228.111 –U username –P Passwordchassis power off
Ipmitool -I lanplus –H 10.32.228.111 –U username –P Passwordchassis power on
Ipmitool -I lanplus –H 10.32.228.111 –U username –P Passwordchassis power reset
Ipmitool -I lanplus –H 10.32.228.111 –U username –P Passwordchassis power cycle
(注意power cycle 和power reset的区别在于前者从掉电到上电有1秒钟的间隔,而后者是很快上电)
读取系统状态类
Ipmitool sensor list 显示系统所有传感器列表
Ipmitool fru list 显示系统所有现场可替代器件的列表
Ipmitool sdr list 显示系统所有SDRRepository设备列表
Ipmitool pef list 显示系统平台时间过滤的列表
3 系统日志类
Ipmitool sel elist 显示所有系统事件日志
Ipmitool sel clear 删除所有系统时间日志
Ipmitool sel delete ID 删除第ID条SEL
Ipmitool sel time get 显示当前BMC的时间
Ipmitool sel time set XXX 设置当前BMC的时间
启动设置类
Ipmitool chassis bootdev bios 重启后停在BIOS 菜单
Ipmitool chassis bootdev pxe 重启后从PXE启动
系统相关的命令
Ipmitool mc info 显示BMC版本信息
Ipmitool bmc reset cold BMC 热启动
Ipmitool bmc reset warmBMC冷启动
网络接口相关命令
Ipmitool lan print 1 显示channel1的网络配置信息
Ipmitool lan set 1ipaddr 10.32.2.2 设置channel1的IP地址
Ipmitool lan set 1 netmask 255.255.0.0 设置channel1的netmask
Ipmitool lan set 4 defgw ipaddr255.255.0.254 设置channel4的网关
Ipmitool lan set 2 defgw macaddr 设置channel2的网关mac address
Ipmitool lan set 2 ipsrc dhcp 设置channel2的ip 源在DHCP
Ipmitool lan set 3 ipsrc static 设置channel2的ip是静态获得的
通道相关命令
Ipmitool channel info 显示系统默认channel
Ipmitool channel authcap channel-number privilege 修改通道的优先级别
Ipmitool channel getaccess channel-number user-id 读取用户在通道上的权限
Ipmitool channel setacccess channel-number user-id callin=on ipmi=on link=onprivilege=5 // 设置用户在通道上的权限
看门狗相关命令
Ipmitool mc watchdog get 读取当前看门狗的设置
Ipmitool watchdog off 关掉看门狗
Ipmitool watchdog reset 在最近设置的计数器的基础上重启看门狗
用户管理相关命令
Ipmitool user list chan-id 显示某通道上的所有用户
Ipmitool set password [] 修改某用户的密码
Ipmitool disable 禁止掉某用户
ipmitool enable 使能某用户
ipmitool priv [] 修改某用户在某通道上的权限
ipmitool test <16|20>[<password]> 测试用户
————————————————
版权声明:本文为CSDN博主「Rudy,Zhao」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_40343504/article/details/82664389
注明:所有转载内容皆直接从被转载文章网页的标题和内容的文本中复制而来
1) 一台可以联接公网的电脑
2) 一个 CentOS 8.2 系统的安装 U 盘
3) 一台可以联接公网并且有公网 IP 地址的 VPS
4) 一个可以联接公网并使用 SSH 和 VNC 的客户端
1) 电脑通过 SSH 建立联接到 VPS 的隧道,此操作会占用 VPS 的一个端口
2) VPS 通过 SSH 将联接电脑的隧道端口映射到一个新的端口
3) 客户端通过 SSH 联接到 VPS 映射出来的新端口,通过 SSH 或远程桌面使用虚拟化平台
4) 客户端和电脑如果在同一内网里则可以通过 Samba 互传数据
(只在电脑上执行以下步骤)
(步骤略)
(
补充:
安装系统时可选择以下选项:
1) 系统起动方式:BIOS
2) Keyboard:English(US)
3) Language Support:English(United States)
4) Time & Date:Asia/ShangHai
5) Installation Source:Local media
6) Software Selection:Minial Install
7) Installation Destination:将主硬盘里的所有空间都分配给根分区
8) KDUMP:Kdump is disabled
9) Network & Host Name:开启网络联接并设置好固定 DNS
10) SECURITY POLICY:No controller found
)
(这里以将 IP 地址设置为固定 IP 地址 192.168.0.1,DNS 设置为固定 DNS 8.8.8.8 为例)
(只在电脑上执行以下步骤)
# yum groupinstall -y "Server with GUI"
(只在电脑上执行以下步骤)
# yum -y install langpacks-zh_CN
(只在电脑上执行以下步骤)
# locale -a
(只在电脑上执行以下步骤)
# yum -y install ibus ibus-libpinyin
(分别在电脑、VPS 和客户端上执行以下步骤)
# useradd zhumingyu
(补充:这里创建用户 zhumingyu 为例)
(分别在电脑、VPS 和客户端上执行以下步骤)
# passwd zhumingyu
(补充:这里创建用户 zhumingyu 为例)
(分别在电脑和 VPS 上执行以下步骤)
# sysctl -w kernel.watchdog_thresh=60
(只在电脑上执行以下步骤)
# vim /etc/sysctl.conf
添加以下内容:
......
kernel.watchdog_thresh=60
(只在电脑上执行以下步骤)
# sysctl -p
(只在电脑上执行以下步骤)
# echo 1 > /proc/sys/kernel/softlockup_panic
(分别在电脑和 VPS 上执行以下步骤)
# vim /etc/sysconfig/network-scripts/ifcfg-enp9s0
添加以下内容:
......
PEERDNS=no
PEERROUTES=no
(补充:这里的 ifcfg-enp9s0 是指网卡对应的配置文件,不同的网卡对应的配置文件不同,这里以网卡名 ifcfg-enp9s0 为例,需要给所有网卡添加此参数,这一步也可以在系统图形系统桌面上设置)
(分别在电脑和 VPS 上执行以下步骤)
# systemctl restart NetworkManager
(只在电脑上执行以下步骤)
(分别在电脑和 VPS 上执行以下步骤)
# vim /etc/ssh/sshd_config
将以下内容:
......
#ClientAliveInterval 0
#ClientAliveCountMax 3
......
修改为:
......
ClientAliveInterval 60
ClientAliveCountMax 525600
......
(补充:这样设置会让 SSH 服务端每 60s 就会尝试连接一次客户端,如果 525600 次后没有回应,则断开)
(分别在电脑和 VPS 上执行以下步骤)
# vim /etc/bashrc
添加以下内容:
......
export TMOUT=0
# vim /etc/profile
添加以下内容:
......
export TMOUT=0
(分别在电脑和 VPS 上执行以下步骤)
# source /etc/bashrc
# source /etc/profile
(步骤略)
(只在电脑上执行以下步骤)
# yum -y install qemu-kvm libvirt-daemon libvirt-client libvirt-daemon-driver-qemu virt-install virt-manager virt-viewer virt-v2v
(只在电脑上执行以下步骤)
# yum -y install samba
(只在电脑上执行以下步骤)
# vim /etc/samba/smb.conf
将全部内容修改如下:
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = WORKGROUP
realm = zhumingyu
netbios name = zhumingyu
#encrypt passwords = yes
map to guest = NEVER
security = user
password server = *
name resolve order = bcast host
restrict anonymous = 2
#null passwords = no
#guest account = smb_nobody
#use spnego = yes
client use spnego = yes
server string = ""
host msdfs = no
msdfs root = no
domain master = no
preferred master = no
local master = no
os level = 0
browse list = no
browseable = no
dns proxy = no
wide links = no
public= no
guest ok = no
hosts deny = ALL EXCEPT 192.168.0.2
[share]
valid users = zhumingyu
write list = zhumingyu
read list = zhumingyu
path = /share
guest ok = no
read only = no
browseable = no
writable = yes
public = no
create mask = 0755
directory mask = 0755
(
补充:
1) 这里以 Samba 服务器的 IP 地址是 192.168.0.1 为例
2) 这里的 workgroup = WORKGROUP 是让 Samba 服务属于 WORKGROUP
3) 这里的 hosts deny = ALL EXCEPT 192.168.0.2 是只让客户端 192.168.0.3 能够访问服务端的 Samba
4) 这里的 sharetest 是这个 Samba 挂载点的名称,挂载这个挂载点的格式就是://192.168.0.1/share
5) 这里的 valid users = zhumingyu 是 Samba 服务共享用户需要手动生成
6) 这里的 path = /share 是 Samba 服务共享目录需要手动生成
)
(只在电脑上执行以下步骤)
# smbpasswd -a zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
# pdbedit -L
(只在电脑上执行以下步骤)
# mkdir /share
(只在电脑上执行以下步骤)
# chmod 755 /share/
(只在电脑上执行以下步骤)
# chown zhumingyu:zhumingyu /share/
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
# semanage fcontext -a -t samba_share_t '/share(/.*)?'
(只在电脑上执行以下步骤)
# restorecon -RFvv /share/
(只在电脑上执行以下步骤)
# systemctl enable --now smb
(只在电脑上执行以下步骤)
# firewall-cmd --add-service=samba --permanent
(只在电脑上执行以下步骤)
# firewall-cmd --reload
(只在电脑上执行以下步骤)
# yum -y install tigervnc tigervnc-server
(只在电脑上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ vncpasswd
(只在电脑上执行以下步骤)
$ exit
(只在电脑上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ vim ~/vnc.sh
创建以下内容:
#!/bin/bash
vncserver -list | grep :1 &> /dev/null || vncserver :1 -localhost -nolisten tcp
(补充:此命令会检查 vncserver :1 会话是否存在,如果不存在,就以禁止非安全远程登陆的方式创建一个)
(只在电脑上执行以下步骤)
$ exit
(只在电脑上执行以下步骤)
# vim /etc/rc.local
添加以下内容:
......
su - zhumingyu -c '/home/zhumingyu/vnc.sh'
(补充:这里以用户 zhumingyu 的身份运行)
或者:
......
su - zhumingyu -c 'vncserver -list | grep :1' &> /dev/null || su - zhumingyu -c 'vncserver :1 -localhost -nolisten tcp'
(
补充:
1) 如果前面没有创建脚本的话,可以只添加上面“或者”后面的这一行
2) 以用户 zhumingyu 的身份运行
3) 此命令会检查 vncserver :1 会话是否存在,如果不存在,就以禁止非安全远程登陆的方式创建一个
)
(只在电脑上执行以下步骤)
# chmod u+x /home/zhumingyu/vnc.sh
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ crontab -e
添加以下内容:
......
0 */1 * * * /home/zhumingyu/vnc.sh
或者:
......
0 */1 * * * vncserver -list | grep :1' &> /dev/null || su - zhumingyu -c 'vncserver :1 -localhost -nolisten tcp
(
补充:
1) 这里以用户 zhumingyu 的身份运行
2) 如果前面没有创建脚本的话,可以只添加上面“或者”后面的这一行
3) 此命令会检查 vncserver :1 会话是否存在,如果不存在,就以禁止非安全远程登陆的方式创建一个
)
(只在电脑上执行以下步骤)
$ exit
(分别在电脑、VPS 和客户端上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(分别在电脑、VPS 和客户端上执行以下步骤)
$ ssh-keygen -b 2048 -t rsa
(补充:建议在创建 SSH 密钥时为 SSH 密钥添加一个密码)
(分别在电脑、VPS 和客户端上执行以下步骤)
$ exit
(分别在电脑、VPS 和客户端上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ ssh-copy-id <public IP address of VPS>
(只在 VPS 上执行以下步骤)
$ ssh-copy-id localhost
$ ssh-copy-id <IP address of computer>
$ ssh-copy-id <public IP address of VPS>
(分别在电脑、VPS 和客户端上执行以下步骤)
$ exit
(只在电脑上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ vim ~/ssh.sh
创建以下内容:
ps -aux | grep -v grep | grep "11000:localhost:22 <IP address of computer>" &> /dev/null || ssh -X -fCNR 11000:localhost:22 <IP address of computer>
(
补充:
1) 这里以用户 zhumingyu 的身份运行
2) 如果 11000 端口没有影射到 22 端口则影射
)
(只在电脑上执行以下步骤)
$ exit
(只在电脑上执行以下步骤)
# vim /etc/rc.local
添加以下内容:
......
su - zhumingyu -c '/home/zhumingyu/ssh.sh'
(补充:这里以用户 zhumingyu 的身份运行)
或者:
......
ps -aux | grep -v grep | grep "11000:localhost:22 <IP address of computer>" &> /dev/null || su - zhumingyu -c 'ssh -X -fCNR 11000:localhost:22 <IP address of computer>'
(
补充:
1) 如果前面没有创建脚本的话,可以只添加上面“或者”后面的这一行
2) 这里以用户 zhumingyu 的身份运行
3) 如果 11000 端口没有影射到 22 端口则影射
)
(只在电脑上执行以下步骤)
# chmod +x /etc/rc.local
(只在电脑上执行以下步骤)
# su - zhumingyu
(补充:这里以 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ crontab -e
添加以下内容:
......
0 */1 * * * /home/zhumingyu/ssh.sh
或者:
......
0 */1 * * * ps -aux | grep -v grep | grep "11000:localhost:22 <IP address of computer>" &> /dev/null || ssh -X -fCNR 11000:localhost:22 <IP address of computer>
(补充:如果 11000 端口影射到 22 端口则影射)
(只在电脑上执行以下步骤)
$ exit
(只在 VPS 上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在 VPS 上执行以下步骤)
$ vim ~/sshd.sh
创建以下内容:
#!/bin/bash
ps -aux | grep -v grep | grep "*:10000:localhost:11000 localhost" || ssh -X -fCNL *:10000:localhost:11000 localhost
(补充:如果 11000 端口没有影射成 10000 端口则影射)
(只在 VPS 上执行以下步骤)
$ exit
(只在 VPS 上执行以下步骤)
# vim /etc/rc.local
添加以下内容:
......
su - zhumingyu -c '/home/zhumingyu/sshd.sh'
(补充:这里以用户 zhumingyu 为例)
或者:
......
ps -aux | grep -v grep | grep "*:10000:localhost:11000 localhost" || su - zhumingyu -c 'ssh -X -fCNL *:10000:localhost:11000 localhost'
(
补充:
1) 如果前面没有创建脚本的话,可以只添加上面“或者”后面的这一行
2) 以用户 zhumingyu 的身份运行
3) 如果 11000 端口没有影射成 10000 端口则影射
)
(只在 VPS 上执行以下步骤)
# chmod +x /etc/rc.local
(只在 VPS 上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在 VPS 上执行以下步骤)
$ crontab -e
添加以下内容:
......
0 */1 * * * /home/zhumingyu/sshd.sh
或者:
......
0 */1 * * * ps -aux | grep -v grep | grep "*:10000:localhost:11000 localhost" || ssh -X -fCNL *:10000:localhost:11000 localhost
(
补充:
1) 如果前面没有创建脚本的话,可以只添加上面“或者”后面的这一行
2) 如果 11000 端口没有影射成 10000 端口则影射
)
(只在 VPS 上执行以下步骤)
$ exit
(只在 VPS 上执行以下步骤)
# firewall-cmd --add-port=10000/tcp --permanent
(补充:这里打开的端口号,是根据前面的设置而定的)
(只在 VPS 上执行以下步骤)
# firewall-cmd --reload
(分别在电脑和 VPS 上执行以下步骤)
# vim /etc/ssh/sshd_config
将以下内容:
......
PermitRootLogin no
......
修改为:
......
PermitRootLogin yes
......
(分别在电脑和 VPS 上执行以下步骤)
# vim /etc/ssh/sshd_config
将以下内容:
......
# PasswordAuthentication yes
......
修改为:
......
PasswordAuthentication no
......
(只在客户端上执行以下步骤)
# ssh -X -p <SSH non standard port number> <user of computer>@<public IP address of VPS>
(
补充:
1) 如果按照前面的步骤操作,这里的 VPS 每小时会生成一个新的 SSH 非标准端口号以用于联接电脑,比如说现在是 14 点,那就会自动生成一个 11014 的 SSH 非标准端口号
2) 如果按照前面的步骤操作,这里的用户是 zhumingyu
)
(只在客户端上执行以下步骤)
# ssh -X <user of computer>@<IP address of computer>
(
补充:
1) 如果按照前面的步骤操作,这里的用户用户是 zhumingyu
2) 如果按照前面的步骤操作,这里的电脑的 IP 地址是 192.168.0.1
)
(只在客户端上执行以下步骤)
# ssh -X -p <SSH non standard port number> <user of computer>@<public IP address of VPS>
(
补充:
1) 如果按照前面的步骤操作,这里的 VPS 每小时会生成一个新的 SSH 非标准端口号以用于联接电脑,比如说现在是 14 点,那就会自动生成一个 11014 的 SSH 非标准端口号
2) 如果按照前面的步骤操作,这里的用户用户是 zhumingyu
)
(只在客户端上执行以下步骤)
# virt-manager
(注意:网络带宽很小则远程桌面会比较卡,建议电脑、客户端和 VPS 的带宽 2m 以上)
(只在客户端上执行以下步骤)
# ssh -X <user of computer>@<IP address of computer>
(
补充:
1) 如果按照前面的步骤操作,这里的用户用户是 zhumingyu
2) 如果按照前面的步骤操作,这里的电脑的 IP 地址是 192.168.0.1
)
(只在客户端上执行以下步骤)
# virt-manager
(注意:网络带宽很小则远程桌面会比较卡,建议电脑、客户端和 VPS 的带宽 2m 以上)
(只在客户端上执行以下步骤)
# ssh -p <SSH non standard port number> -L <port number of VNC>:localhost:<port number of VNC> -l <user of computer> <public IP address of VPS>
(
补充:
1) 如果按照前面的步骤操作,这里的 VPS 每小时会生成一个新的 SSH 非标准端口号以用于联接电脑,比如说现在是 14 点,那就会自动生成一个 11014 的 SSH 非标准端口号
2) 如果按照前面的步骤操作,这里的 VNC 的端口号是 5901
3) 如果按照前面的步骤操作,这里的电脑的用户用户是 zhumingyu
)
另开启一个命令行终端:
# vncviewer localhost :<number of VNC service>
(补充:如果按照前面的步骤操作,这里的 VNC 服务的编号是 1)
(注意:网络带宽很小则远程桌面会比较卡,建议电脑、客户端和 VPS 的带宽 2m 以上)
(只在客户端上执行以下步骤)
# vncviewer -via <user of computer>@<IP address of computer> localhost :<number of VNC service>
(
补充:
1) 如果按照前面的步骤操作,这里的电脑的用户是 zhumingyu
2) 如果按照前面的步骤操作,这里的电脑的 IP 地址是 192.168.0.1
3) 如果按照前面的步骤操作,这里的 VNC 服务的编号是 1
)
(只在客户端上执行以下步骤)
在文件目录下栏输入以下内容:
\\<IP address of computer>\<samba directory>
(
补充:
1) 如果按照前面的步骤操作,这里的电脑的 IP 地址是 192.168.0.1
2) 如果按照前面的步骤操作,这里的 Samba 项目是 share
)
(
注意:
1) 如果按照前面的步骤操作,只有 IP 地址是 192.168.0.2 和 192.168.0.3 的客户端才能够执行以上步骤
2) Windows 客户端建议安装 SecureCRT、Xmanager 和 VNC 客户端以实现 ssh、ssh 调用 virt-manager 和 VNC
)
(只在客户端上执行以下步骤)
在文件 –> 其他位置 –> 连接到服务器的地址栏里输入以下内容:
smb://<IP address of computer>/<samba directory>
(
补充:
1) 如果按照前面的步骤操作,这里的电脑的 IP 地址是 192.168.0.1
2) 如果按照前面的步骤操作,这里的 Samba 项目是 share
)
(注意:如果按照前面的步骤操作,只有 IP 地址是 192.168.0.2 和 192.168.0.3 的客户端才能够执行以上步骤)
网关路由器拥有 IP 地址(可以通过给宽带申请公网 IP 地址并将光纤盒设置为桥接模式,在路由器上添加用户和密码实现)
(步骤略)
由于大多数的公网 IP 地址都是动态,定期会变,所以可以通过此方法知道近期的公网 IP 地址是多少
(只在电脑上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ vim /root/computerip.sh
创建以下内容:
#!/bin/bash
computerip=`curl ifconfig.me`
domain=<public IP address of VPS>
ssh athenadb.com \"echo `curl ifconfig.me` > /home/zhumingyu/serverip.txt\"
(补充:将电脑的公网 IP 地址拷贝到 VPS 的 /tmp/computerip.txt 文件里为例)
(只在电脑上执行以下步骤)
$ exit
(只在电脑上执行以下步骤)
# su - zhumingyu
(补充:这里以用户 zhumingyu 为例)
(只在电脑上执行以下步骤)
$ crontab -e
添加以下内容:
......
0 */10 * * * /home/zhumingyu/.crontab/computerip.txt
或者:
......
ssh <public IP address of VPS> \"echo `curl ifconfig.me` > /home/zhumingyu/serverip.txt\"
(
补充:
1) 如果前面没有创建脚本的话,可以只添加上面“或者”后面的这一行
2) 将电脑的公网 IP 地址拷贝到 VPS 的 /home/zhumingyu/serverip.txt 文件里
)
(只在电脑上执行以下步骤)
$ exit
由于大多数的公网 IP 地址都是动态,定期会变,所以可以通过此方法知道近期的公网 IP 地址是多少
(步骤略)
# lspci | grep -i fibre
# ls /sys/class/fc_host/
host1 host2 host3 host4
# cat /sys/class/fc_host/host[1-4]/port_name
# cat /sys/class/fc_host/host5/port_state
online
# cat /sys/class/fc_host/host7/port_state
linkdown
# nmcli network on
或者:
# nmcli net on
# nmcli network off
或者:
# nmcli net off
# nmcli connection show
或者:
# nmcli conneciton
或者:
# nmcli con show
或者:
# nmcli con
# nmcli connection show --active
或者:
# nmcli conneciton --active
或者:
# nmcli con show --active
或者:
# nmcli con --active
# nmcli device connect <network device name>
或者:
# nmcli dev con <network device name>
# nmcli device status
或者:
# nmcli dev status
# nmcli connection add con-name <custom network card alias> ifname <network device name> type ethernet
(补充:这里 con-name 是指要指定一个自定义的网卡别名,ifname 是指要指明网络设备名)
或者:
# nmcli con add con-name <custom network card alias> ifname <network device name> type ethernet
(补充:这里 con-name 是指要指定一个自定义的网卡别名,ifname 是指要指明网络设备名)
# nmcli connection delete <custom network card alias>
或者:
# nmcli con del <custom network card alias>
# nmcli device connect <network device name>
或者:
# nmcli dev con <network device name>
# nmcli device disconnect <network device name>
或者:
# nmcli dev dis <network device name>
# nmcli connection modify <custom network card alias> ipv4.address <IP address>/<subnet mask> ipv4.gateway <gateway IP address> ipv4.dns <DNS IP address> autoconnect yes
# nmcli connection modify eth0 ipv4.address 192.168.1.1/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.254 autoconnect yes
(补充:这里以添加给 eth0 添加 IP 地址 192.168.1.1/24,网关 192.168.1.1,DNS 192.168.1.254 为例)
# nmcli connection up <custom network card alias>
# nmcli connection down eth0
# nmcli con mod <custom network card alias> ipv4.routes "<network segment> <gateway IP address>"
# nmcli con mod eth0 ipv4.routes "192.168.2.0/24 192.168.3.1"
(补充:这里以给 eth0 网卡添加 192.168.2.0/24 通过 192.168.3.1 的网关为例)
# nmcli connection up <custom network card alias>
# nmcli connection up eth0
(补充:这里以让 eth0 生效为例)