1. 程式人生 > >nmcli和nmtui命令雜記

nmcli和nmtui命令雜記

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命令雜記