码迷,mamicode.com
首页 > 其他好文 > 详细

nmcli和nmtui命令杂记

时间:2018-03-26 21:31:56      阅读:650      评论:0      收藏:0      [点我收藏+]

标签:linux 网络配置 杂记 基础

CetnOS7网络配置

取消系统网卡自动命名

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

[root@CentOS7 ~]# 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

[root@CentOS7 ~]# init 6

1 nmcli

[root@CentOS7 ~]# nmcli g status
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled 

1.1 nmcli-device

查看接口设备状态

[root@CentOS7 ~]# nmcli device status
DEVICE  TYPE      STATE      CONNECTION 
eth0    ethernet  connected  eth0       
lo      loopback  unmanaged  --    

查看eth0接口详细信息

[root@CentOS7 ~]# 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

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

[root@CentOS7 ~]# 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  --  

查看支持的语言

[root@CentOS7 ~]# localectl list-locales | grep en.

修改语言环境

[root@CentOS7 ~]# localectl set-locale LANG=en_US.utf8

重启网络服务(CentOS7)

[root@CentOS7 network-scripts]# systemctl restart NetworkManager[root@CentOS7 network-scripts]# systemctl restart network

添加第二地址

[root@CentOS7 ~]# nmcli c modify eth0 +ipv4.addresses 10.201.106.222/24

禁用并启用网络接口

[root@CentOS7 ~]# 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)

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

[root@CentOS7 ~]# nmcli connection modify eth0 -ipv4.addresses 10.201.106.222/24

[root@CentOS7 ~]# 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)
[root@CentOS7 ~]# 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

[root@CentOS7 ~]# nmcli connection modify eth0 ipv4.gateway 10.201.106.2 ipv4.dns 10.201.106.2 +ipv4.dns 8.8.8.8 
[root@CentOS7 ~]# 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)
[root@CentOS7 ~]# 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

查看主机名

[root@CentOS7 ~]# 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

修改主机名

[root@CentOS7 ~]# hostnamectl set-hostname qq
[root@CentOS7 ~]# hostname
qq

网络小工具

lftp

登陆文件服务器

[root@CentOS7 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链接下载软件

[root@CentOS7 tmp]# lftpget ftp://10.201.106.128/pub/110.txt
get1: 110.txt: File exists  

ftp(比lftp还要古老)

匿名登陆

[root@CentOS7 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> 

nmcli和nmtui命令杂记

标签:linux 网络配置 杂记 基础

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!