nmcli和nmtui命令杂记

CetnOS7网络配置

取消系统网卡自动命名

[[email protected] ~]# vim /etc/default/grub
GRUB_CMDLINE_LINUX="net.ifnames=0 crashkernel=auto rhgb quiet"

[[email protected] ~]# grub2-mkconfig -o /etc/grub2.cfg  #重启生成配置
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-749597373cb946aa90c4209f5895777f
Found initrd image: /boot/initramfs-0-rescue-749597373cb946aa90c4209f5895777f.img
done

[[email protected] ~]# init 6

1 nmcli

[[email protected] ~]# nmcli g status
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN
connected  full          enabled  enabled  enabled  enabled 

1.1 nmcli-device

查看接口设备状态

[[email protected] ~]# nmcli device status
DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  eth0
lo      loopback  unmanaged  --    

查看eth0接口详细信息

[[email protected] ~]# nmcli device show eth0
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:A7:7A:EC
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eth0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/4
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.201.106.131/24
IP4.ADDRESS[2]:                         10.201.106.130/24
IP4.GATEWAY:                            10.201.106.2
IP6.ADDRESS[1]:                         fe80::20c:29ff:fea7:7aec/64
IP6.GATEWAY:

1.2 nmcli-connect

显示当前所有可用状态的连接

[[email protected] ~]# nmcli connect show
NAME                UUID                                  TYPE            DEVICE
eth0                cc0a4203-e54a-4089-8495-52ddf502947d  802-3-ethernet  eth0
Wired connection 1  daa49f62-6735-4a92-9fbe-227c9e036110  802-3-ethernet  --
ens33               7b110e50-0afe-42e1-862b-f597400a572c  802-3-ethernet  --  

查看支持的语言

[[email protected] ~]# localectl list-locales | grep en.

修改语言环境

[[email protected] ~]# localectl set-locale LANG=en_US.utf8

重启网络服务(CentOS7)

[[email protected] network-scripts]# systemctl restart NetworkManager[[email protected] network-scripts]# systemctl restart network

添加第二地址

[[email protected] ~]# nmcli c modify eth0 +ipv4.addresses 10.201.106.222/24

禁用并启用网络接口

[[email protected] ~]# nmcli connection down eth0;nmcli connection up eth0
Connection ‘eth0‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)

删除地址,需要重启接口生效

[[email protected] ~]# nmcli connection modify eth0 -ipv4.addresses 10.201.106.222/24

[[email protected] ~]# nmcli connection down eth0; nmcli connection up eth0
Connection ‘eth0‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/0)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
[[email protected] ~]# nmcli dev show eth0
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:A7:7A:EC
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eth0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/2
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.201.106.133/24
IP4.ADDRESS[2]:                         10.201.106.130/24
IP4.GATEWAY:                            10.201.106.2
IP4.DNS[1]:                             10.201.106.2
IP4.DOMAIN[1]:                          localdomain
IP6.ADDRESS[1]:                         fe80::20c:29ff:fea7:7aec/64
IP6.GATEWAY:       

修改网关,修改和增加DNS

[[email protected] ~]# nmcli connection modify eth0 ipv4.gateway 10.201.106.2 ipv4.dns 10.201.106.2 +ipv4.dns 8.8.8.8
[[email protected] ~]# nmcli connection down eth0; nmcli connection up eth0
Connection ‘eth0‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
[[email protected] ~]# nmcli dev show eth0
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:A7:7A:EC
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eth0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/3
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.201.106.133/24
IP4.ADDRESS[2]:                         10.201.106.130/24
IP4.GATEWAY:                            10.201.106.2
IP4.DNS[1]:                             10.201.106.2
IP4.DNS[2]:                             8.8.8.8
IP4.DOMAIN[1]:                          localdomain
IP6.ADDRESS[1]:                         fe80::20c:29ff:fea7:7aec/64
IP6.GATEWAY:

2 nmtui

3 hostnamectl

查看主机名

[[email protected] ~]# hostnamectl status
   Static hostname: CentOS7.2.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 749597373cb946aa90c4209f5895777f
           Boot ID: 9be2af2f19f147928f7db61e825111ed
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64

修改主机名

[[email protected] ~]# hostnamectl set-hostname qq
[[email protected] ~]# hostname
qq

网络小工具

lftp

登陆文件服务器

[[email protected] tmp]# lftp 10.201.106.128
lftp 10.201.106.128:~> ls
drwxr-xr-x    2 0        0            4096 Jun 16 04:01 pub
lftp 10.201.106.128:/> 

下载单个软件和多个软件

lftp 10.201.106.128:/pub> get 110.txt    ###下载单个
get: /tmp/110.txt: File exists
lftp 10.201.106.128:/pub>
lftp 10.201.106.128:/pub>
lftp 10.201.106.128:/pub> mget ./*      ###下载多个
mget: /tmp/110.txt: File exists 

基于ftp链接下载软件

[[email protected] tmp]# lftpget ftp://10.201.106.128/pub/110.txt
get1: 110.txt: File exists  

ftp(比lftp还要古老)

匿名登陆

[[email protected] tmp]# ftp 10.201.106.128
Connected to 10.201.106.128 (10.201.106.128).
220 (vsFTPd 2.2.2)
Name (10.201.106.128:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (10,201,106,128,35,197).
150 Here comes the directory listing.
drwxr-xr-x    2 0        0            4096 Jun 16 04:01 pub
226 Directory send OK.
ftp> 

原文地址:http://blog.51cto.com/zhongle21/2091354

时间: 2024-11-01 20:52:57

nmcli和nmtui命令杂记的相关文章

MySQL 命令杂记

mysql> show processlist; 如果是root帐号,你能看到所有用户的当前连接.如果是其它普通帐号,只能看到自己占用的连接.show processlist;只列出前100条,如果想全列出请使用show full processlist; mysql> show status; mysql> show status like '%下面变量%'; Aborted_clients 由于客户没有正确关闭连接已经死掉,已经放弃的连接数量. Aborted_connects 尝试

RedHat7中nmcli和nmtui说明

网络管理工具NetworkManager包含命令行工具和文本界面工具 nmcli:网络管理命令行接口:NetworkManager Command-Line Interface nmtui:网络管理文本用户接口:NetworkManager Text-User Interface [使用nmcli添加网络配置] nmcli connection add con-name c1 ifname eno16777736 type ethernet ip3 1.2.3.4/8 gw4 1.1.1.1

#21 nmcli、nmtui与网络组详解

nmcli命令: command‐line tool for controlling NetworkManager nmcli  [ OPTIONS ] OBJECT { COMMAND | help } OBJECT:connection | device device - show and manage network interfaces COMMAND := { status | show | connect | disconnect | delete | wifi | wimax }

linux命令杂记

ping带时间戳: ping 10.23.46.37 -c 10000 | awk '{ print $0"\t" strftime("%H:%M:%S",systime()) } ' 批量执行命令,比如批量无视依赖卸载: rpm -qa|grep 包名|xargs rpm -e --nodeps 批量杀进程: ps ax|grep 进程名|awk '{print $1}' | xargs kill -9 挂载光盘镜像: mount -t iso9660 -o lo

Linux基础命令杂记

今天又一次搞Linux生产环境搭建.这是种步骤很多,很繁琐而且又不得不做的事情.虽然做过很多次,但还是有很多步骤.命令不记得,每一次到处找资料很麻烦,于是将一些步骤记下,以便查找. 登录远程MySQL mysql -h 192.168.1.100 -u root -p 给MySQl非root账户分配权限 给账号user1 密码为123456 的用户testDB数据库的所有表的select,insert,update,delete权限: grant select,insert,update,del

linux-ip命令杂记

11.3 ip命令 11.3.1 ip 查看ip是由哪个rpm生成的 [[email protected] ~]# rpm -qf `which ip` iproute-2.6.32-32.el6_5.i686 查看iproute生成的文件 [[email protected] ~]# rpm -ql iproute /etc/iproute2 /etc/iproute2/ematch_map /etc/iproute2/rt_dsfield /etc/iproute2/rt_protos /e

openssl命令杂记

openssl命令行 openssl基础 显示openssl版本号 [[email protected] ~]# openssl version OpenSSL 1.0.1e-fips 11 Feb 2013 [[email protected] ~]# enc [[email protected] ~]# whatis enc enc (1ssl) - symmetric cipher routines 给文件加密 [[email protected] tmp]# openssl enc -e

MongoDB基础命令杂记

一.MongoDB安装使用 1.安装启动MongoDB 1.1 下载安装 官网: https://www.mongodb.com/ rpm下载地址: http://mirrors.aliyun.com/mongodb/yum/redhat/7/mongodb-org/ [[email protected] ~]# ls mongodb-3.0.0/ mongodb-org-3.0.0-1.el7.x86_64.rpm mongodb-org-mongos-3.0.0-1.el7.x86_64.r

linux常用命令杂记(一)--Lsof

lsof的用法 lsof全名list opened files,也就是列举系统中已经被打开的文件.linux环境中,任何事物都是文件,设备是文件,目录是文件,甚至sockets也是文件.所以,用好lsof命令,对日常的linux管理非常有帮助. lsof是linux最常用的命令之一,通常的输出格式为:#lsof +d /usr/local/#lsof -i :22 知道22端口现在运行什么程序等等查看相应用法可以查看man帮助查找对应选项:man lsof 常见包括如下几个字段: 1.COMMA