查看网络:

Ifconfig==interface config

ip add show

 

网络的服务:

NetworkManager

systemctl status NetworkManager

 

通过NM提供的命令工具是支持命令补全的

该服务不仅可以管理接口 还可以管理连接 connections

该服务提供了图形化的管理工具和命令行的管理工具,推荐命令行

nm-connection-editor

 

nmcli  命令行

nmcli connection 和连接有关的配置

[root@rhce7-0 ~]# nmcli connection show

NAME                UUID                                                                     TYPE                    DEVICE

eno16777736  15a24c40-21de-4a5b-8690-3c51d0325845  802-3-ethernet  eno16777736

 

[root@rhce7-0 ~]# nmcli connection add

autoconnect  con-name     help         ifname       type

[root@rhce7-0 ~]# #nmcli connection add

[root@rhce7-0 ~]# #autoconnect表示,当该连接指定的网卡可以正常使用的时候 该con会自动连接

[root@rhce7-0 ~]# #con-name表示建立的连接名称

[root@rhce7-0 ~]# #ifname 表示建立的连接是为哪个接口使用的

[root@rhce7-0 ~]# #type 表示该con的类型,而是连接所指定的interface 的类型

[root@rhce7-0 ~]#

 

[root@rhce7-0 ~]# nmcli connection add con-name test ifname eno16777736 type ethernet autoconnect yes ip4 192.168.80.124/24 gw4 192.168.80.1

Connection ‘test’ (9bcd4ffc-45b3-46c9-ae3e-0be5c46ce469) successfully added.

 

[root@rhce7-0 ~]# nmcli connection up test

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)

[root@rhce7-0 ~]# ifconfig

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

inet 192.168.80.124  netmask 255.255.255.255  broadcast 192.168.80.124

inet6 fe80::20c:29ff:fed3:e31  prefixlen 64  scopeid 0x20<link>

ether 00:0c:29:d3:0e:31  txqueuelen 1000  (Ethernet)

RX packets 9  bytes 1952 (1.9 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 636  bytes 44439 (43.3 KiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

inet 127.0.0.1  netmask 255.0.0.0

inet6 ::1  prefixlen 128  scopeid 0x10<host>

loop  txqueuelen 0  (Local Loopback)

RX packets 518  bytes 49456 (48.2 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 518  bytes 49456 (48.2 KiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

[root@rhce7-0 ~]# nmcli connection show

NAME         UUID                                  TYPE            DEVICE

test         9bcd4ffc-45b3-46c9-ae3e-0be5c46ce469  802-3-ethernet  eno16777736

eno16777736  15a24c40-21de-4a5b-8690-3c51d0325845  802-3-ethernet  —

[root@rhce7-0 ~]# nmcli connection down test

[root@rhce7-0 ~]# nmcli connection show

NAME         UUID                                  TYPE            DEVICE

test         9bcd4ffc-45b3-46c9-ae3e-0be5c46ce469  802-3-ethernet  —

eno16777736  15a24c40-21de-4a5b-8690-3c51d0325845  802-3-ethernet  eno16777736

[root@rhce7-0 ~]# nmcli connection delete test

[root@rhce7-0 ~]# nmcli connection show

NAME         UUID                                  TYPE            DEVICE

eno16777736  15a24c40-21de-4a5b-8690-3c51d0325845  802-3-ethernet  eno16777736

[root@rhce7-0 ~]#

修改IP配置从DHCP-STATIC之间: 必须加上ipv4.method manual/auto 不然不能生效

[root@rhce7-0 ~]# nmcli connection modify eno16777736 ipv4.addresses “192.168.80.150/24 192.168.80.1” ipv4.method manual/auto

 

主机名修改:

永久修改主机名:(必须退出当前shell 重新登录)

hostnamectl set-hostname  主机名

临时修改主机名:(当前shell生效)

hostname 主机名

主机名本地解析配置文件

/etc/hosts

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

© 2018 Mr. Xiao's Blog Suffusion theme by Sayontan Sinha