CentOS 7网络配置工具

                       作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.网卡命名机制

CentOS 6之前,网络接口使用连续号码命名:eth0、eth1等,当增加或删除网卡时,名称可能会发生变化

CentOS 7使用基于硬件,设备拓扑和设置类型命名,systemd对网络设备的命名方式规则如下:
  ()如果Firmware或BIOS为主板上集成的设备提供的索引信息可用,且可预测则根据此索引进行命名,例如eno1
  ()如果Firmware或BIOS为PCI-E扩展槽所提供的索引信息可用,且可预测,则根据此索引进行命名,例如ens1
  ()如果硬件接口的物理位置信息可用,则根据此信息进行命名,例如enp2s0
  ()如果用户显式启动,也可根据MAC地址进行命名,例如enx2387a1dc56
  ()上述均不可用时,则使用传统命名机制,例如:eth0,eth1 为什么CentOS 6和CentOS 7之间网卡命名会有如此大的变化呢?
  因为早期有客户反应为服务器扩展物理网卡时出现了配置文件与服务器网卡不对应的情况。如,原来服务器只有一块网卡,运维人员为其定义了一个配置文件"ifcf-eth0",当添加第二块物理网卡时,发现重启操作后,之前定义的"ifcf-eth0"配置文件竟然识别了新的物理网卡的显现!由此,对网卡的命名推出了以上一系列措施,不过看上面的策略看起来还是不错的。
  由于生成环境中我们很少碰到频繁更换物理网卡的现象,我们可以采用传统式命名,为了运维自动化打好基础,首先得标准化(我们先从网卡命名规则统一开始)。

1>.基于BIOS支持启用biosdevname(dell公司研发)软件

Dell服务器的内置网卡命名规则:
  em1,em2
Dell外接的pci网卡命名规则:
  pYpX Y:slot ,X:port

2>.名称组成格式

en: 
  Ethernet 有线局域网
wl:
  wlan 无线局域网
ww:
  wwan无线广域网

3>.名称类型

o<index>:
  集成设备的设备索引号
s<slot>:
  扩展槽的索引号
x<MAC>:
  基于MAC地址的命名
p<bus>s<slot>:
  基于硬件接口的物理位置信息如:enp2s1

4>.采用传统命名方式

具体步骤如下:
  ()编辑/etc/default/grub配置文件(或:修改/boot/grub2/grub.cfg)
  GRUB_CMDLINE_LINUX="... rhgb quiet net.ifnames=0"   ()为grub2生成其配置文件
  grub2-mkconfig -o /etc/grub2.cfg(该文件是一个软连接)
  ()重启系统   (4)别忘记修改网卡的配置文件哟~
[root@node101.yinzhengjie.org.cn ~]# cat /etc/default/grub
GRUB_TIMEOUT=
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# vim /etc/default/grub
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/default/grub
GRUB_TIMEOUT=
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# vim /etc/default/grub

[root@node101.yinzhengjie.org.cn ~]# cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
# ### BEGIN /etc/grub.d/00_header ###
set pager= if [ -s $prefix/grubenv ]; then
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="${saved_entry}"
fi if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi export menuentry_id_option if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
} function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
} terminal_output console
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=
fi
### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
set tuned_initrd=""
### END /etc/grub.d/00_tuned ### ### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
source ${prefix}/user.cfg
if [ -n "${GRUB2_PASSWORD}" ]; then
set superusers="root"
export superusers
password_pbkdf2 root ${GRUB2_PASSWORD}
fi
fi
### END /etc/grub.d/01_users ### ### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menue
ntry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-7e5d6996-5762-4909-8717-6dd8d6d30a0e' { load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd
,msdos1' 343e9f9c-8324-4918-a10d-541627af8e04 else
search --no-floppy --fs-uuid --set=root 343e9f9c---a10d-541627af8e04
fi
linux16 /vmlinuz-3.10.-.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/
swap rhgb quiet LANG=en_US.UTF- #温馨提示,其实咱们也可以直接修改这里,在这后面直接添加"net.ifnames=0"即可。
initrd16 /initramfs-3.10.-.el7.x86_64.img
}
menuentry 'CentOS Linux (0-rescue-9ccdf621e5984f3b8626614f6fa15a48) 7 (Core)' --class centos --class gnu-linux --class gnu --class os -
-unrestricted $menuentry_id_option 'gnulinux-0-rescue-9ccdf621e5984f3b8626614f6fa15a48-advanced-7e5d6996-5762-4909-8717-6dd8d6d30a0e' { load_video
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd
,msdos1' 343e9f9c-8324-4918-a10d-541627af8e04 else
search --no-floppy --fs-uuid --set=root 343e9f9c---a10d-541627af8e04
fi
linux16 /vmlinuz--rescue-9ccdf621e5984f3b8626614f6fa15a48 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/ro
ot rd.lvm.lv=centos/swap rhgb quiet
initrd16 /initramfs--rescue-9ccdf621e5984f3b8626614f6fa15a48.img
} ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ### ### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# cat /boot/grub2/grub.cfg   #其实也可以直接修改该文件,但不推荐,建议修改"/etc/default/grub"(该文件会参考"/etc/defaullt/grub"做响应的调整,该文件的注释有说明)

[root@node101.yinzhengjie.org.cn ~]# ll /etc/grub2.cfg
lrwxrwxrwx. root root Jul : /etc/grub2.cfg -> ../boot/grub2/grub.cfg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# grub2-mkconfig -o /etc/grub2.cfg    #为grub2生成其配置文件
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.-.el7.x86_64
Found initrd image: /boot/initramfs-3.10.-.el7.x86_64.img
Found linux image: /boot/vmlinuz--rescue-9ccdf621e5984f3b8626614f6fa15a48
Found initrd image: /boot/initramfs--rescue-9ccdf621e5984f3b8626614f6fa15a48.img
done
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# grub2-mkconfig -o /etc/grub2.cfg    #为grub2生成其配置文件

二.CentOS 7网络配置工具-nmcli命令

1>.CentOS 7网络配置工具概述

图形工具:nm-connection-editor

字符配置tui工具:nmtui

命令行工具:nmcli

2>.nmcli支持命令补全(最小化安装需要安装额外的包)

[root@node104.yinzhengjie.org.cn ~]# yum -y install bash-completion.noarch
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirror.jdcloud.com
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
base | 3.6 kB ::
extras | 2.9 kB ::
updates | 2.9 kB ::
(/): base//x86_64/group_gz | kB ::
(/): extras//x86_64/primary_db | kB ::
(/): base//x86_64/primary_db | 6.0 MB ::
(/): updates//x86_64/primary_db | 4.2 MB ::
Resolving Dependencies
--> Running transaction check
---> Package bash-completion.noarch :2.1-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Installing:
bash-completion noarch :2.1-.el7 base k Transaction Summary
=================================================================================================================================================
Install Package Total download size: k
Installed size: k
Downloading packages:
bash-completion-2.1-.el7.noarch.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : :bash-completion-2.1-.el7.noarch /
Verifying : :bash-completion-2.1-.el7.noarch / Installed:
bash-completion.noarch :2.1-.el7 Complete!
[root@node104.yinzhengjie.org.cn ~]#

[root@node104.yinzhengjie.org.cn ~]# yum -y install bash-completion.noarch

3>.查看网卡的状态(如当前主机的接口是否正常)

[root@node101.yinzhengjie.org.cn ~]# nmcli device
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected Wired connection
eth1 ethernet connected System eth1
lo loopback unmanaged --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli device

3>.显示所有(包括不活动)连接

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s8
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-eth1
-rw-r--r--. root root Aug /etc/sysconfig/network-scripts/ifcfg-lo
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show

4>.显示所有活动连接

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show --active
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show --active

5>.显示网络连接配置

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show System\ eth1
connection.id: System eth1
connection.uuid: 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
connection.stable-id: --
connection.type: --ethernet
connection.interface-name: eth1
connection.autoconnect: yes
connection.autoconnect-priority:
connection.autoconnect-retries: - (default)
connection.auth-retries: -
connection.timestamp:
connection.read-only: no
connection.permissions: --
connection.zone: --
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: - (default)
connection.secondaries: --
connection.gateway-ping-timeout:
connection.metered: unknown
connection.lldp: default
connection.mdns: - (default)
--ethernet.port: --
--ethernet.speed:
--ethernet.duplex: --
--ethernet.auto-negotiate: no
--ethernet.mac-address: --
--ethernet.cloned-mac-address: --
--ethernet.generate-mac-address-mask:--
--ethernet.mac-address-blacklist: --
--ethernet.mtu: auto
--ethernet.s390-subchannels: --
--ethernet.s390-nettype: --
--ethernet.s390-options: --
--ethernet.wake-on-lan: default
--ethernet.wake-on-lan-password: --
ipv4.method: manual
ipv4.dns: 172.30.1.254
ipv4.dns-search: --
ipv4.dns-options: ""
ipv4.dns-priority:
ipv4.addresses: 172.30.1.101/
ipv4.gateway: 172.30.1.254
ipv4.routes: --
ipv4.route-metric: -
ipv4.route-table: (unspec)
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-timeout: (default)
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.dhcp-fqdn: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv4.dad-timeout: - (default)
ipv6.method: ignore
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: ""
ipv6.dns-priority:
ipv6.addresses: --
ipv6.gateway: --
ipv6.routes: --
ipv6.route-metric: -
ipv6.route-table: (unspec)
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: - (unknown)
ipv6.addr-gen-mode: stable-privacy
ipv6.dhcp-duid: --
ipv6.dhcp-send-hostname: yes
ipv6.dhcp-hostname: --
ipv6.token: --
proxy.method: none
proxy.browser-only: no
proxy.pac-url: --
ipv6.dhcp-duid: --
ipv6.dhcp-send-hostname: yes
ipv6.dhcp-hostname: --
ipv6.token: --
proxy.method: none
proxy.browser-only: no
proxy.pac-url: --
proxy.pac-script: --
GENERAL.NAME: System eth1
GENERAL.UUID: 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
GENERAL.DEVICES: eth1
GENERAL.STATE: activated
GENERAL.DEFAULT: no
GENERAL.DEFAULT6: no
GENERAL.SPEC-OBJECT: --
GENERAL.VPN: no
GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/
GENERAL.ZONE: --
GENERAL.MASTER-PATH: --
IP4.ADDRESS[]: 172.30.1.101/
IP4.GATEWAY: 172.30.1.254
IP4.ROUTE[]: dst = 172.30.1.0/, nh = 0.0.0.0, mt =
IP4.ROUTE[]: dst = 0.0.0.0/, nh = 172.30.1.254, mt =
IP4.DNS[]: 172.30.1.254
IP6.GATEWAY: --

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show System\ eth1   #推荐使用tab自动补齐

6>.显示设备状态

[root@node101.yinzhengjie.org.cn ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected Wired connection
eth1 ethernet connected System eth1
lo loopback unmanaged --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli dev status
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected Wired connection
eth1 ethernet connected System eth1
lo loopback unmanaged --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli device status

7>.显示网络接口属性

[root@node101.yinzhengjie.org.cn ~]# nmcli device show eth1
GENERAL.DEVICE: eth1
GENERAL.TYPE: ethernet
GENERAL.HWADDR: :::C1:C7:
GENERAL.MTU:
GENERAL.STATE: (connected)
GENERAL.CONNECTION: System eth1
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[]: 172.30.1.101/
IP4.GATEWAY: 172.30.1.254
IP4.ROUTE[]: dst = 172.30.1.0/, nh = 0.0.0.0, mt =
IP4.ROUTE[]: dst = 0.0.0.0/, nh = 172.30.1.254, mt =
IP4.DNS[]: 172.30.1.254
IP6.GATEWAY: --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli device show eth1

8>.创建新连接default的配置文件,IP自动通过dhcp获取

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection add con-name default type ethernet ifname eth2
Connection 'default' (ccf4df33-797b-4ab3-8cf0-cc2f39691040) successfully added.
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
default ccf4df33-797b-4ab3-8cf0-cc2f39691040 ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-default
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s8
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-eth1
-rw-r--r--. root root Aug /etc/sysconfig/network-scripts/ifcfg-lo
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/sysconfig/network-scripts/ifcfg-default
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=default
UUID=ccf4df33-797b-4ab3-8cf0-cc2f39691040
DEVICE=eth2
ONBOOT=yes
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection add con-name default type ethernet ifname eth2

9>.删除连接default的配置文件

[root@node101.yinzhengjie.org.cn ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-default
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s8
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-eth1
-rw-r--r--. root root Aug /etc/sysconfig/network-scripts/ifcfg-lo
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
default ccf4df33-797b-4ab3-8cf0-cc2f39691040 ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection delete default
Connection 'default' (ccf4df33-797b-4ab3-8cf0-cc2f39691040) successfully deleted.
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s8
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-eth1
-rw-r--r--. root root Aug /etc/sysconfig/network-scripts/ifcfg-lo
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection delete default

10>.创建新连接static的配置文件 ,指定静态IP,不自动连接

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection add con-name static ifname eth2 autoconnect no type ethernet ipv4.addresses 172.30.1.100/ ipv4.gateway 172.30.1.254
Connection 'static' (c004fcc2--4e0d-a132-8e28b2582fad) successfully added.
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s8
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-eth1
-rw-r--r--. root root Aug /etc/sysconfig/network-scripts/ifcfg-lo
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-static
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/sysconfig/network-scripts/ifcfg-static
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
IPADDR=172.30.1.100
PREFIX=
GATEWAY=172.30.1.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=static
UUID=c004fcc2--4e0d-a132-8e28b2582fad
DEVICE=eth2
ONBOOT=no
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection add con-name static ifname eth2 autoconnect no type ethernet ipv4.addresses 172.30.1.100/24 ipv4.gateway 172.30.1.254

11>.禁用连接配置

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection down Wired\ connection\
Connection 'Wired connection 1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/)
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
Wired connection 80a31b55---8aae-5154a3b47040 ethernet --
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection down Wired\ connection\ 1

12>.启用连接配置(前提是该配置文件绑定的设备的确存在,否则会报错设备不存在哟~)

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
Wired connection 80a31b55---8aae-5154a3b47040 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection up Wired\ connection\
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/)
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection up Wired\ connection\ 1

13>.查看帮助

[root@node101.yinzhengjie.org.cn ~]# nmcli connection add help
Usage: nmcli connection add { ARGUMENTS | help } ARGUMENTS := COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS SLAVE_OPTIONS IP_OPTIONS [-- ([+|-]<setting>.<property> <value>)+] COMMON_OPTIONS:
type <type>
ifname <interface name> | "*"
[con-name <connection name>]
[autoconnect yes|no]
[save yes|no]
[master <master (ifname, or connection UUID or name)>]
[slave-type <master connection type>] TYPE_SPECIFIC_OPTIONS:
ethernet: [mac <MAC address>]
[cloned-mac <cloned MAC address>]
[mtu <MTU>] wifi: ssid <SSID>
[mac <MAC address>]
[cloned-mac <cloned MAC address>]
[mtu <MTU>]
[mode infrastructure|ap|adhoc] wimax: [mac <MAC address>]
[nsp <NSP>] pppoe: username <PPPoE username>
[password <PPPoE password>]
[service <PPPoE service name>]
[mtu <MTU>]
[mac <MAC address>] gsm: apn <APN>
[user <username>]
[password <password>] cdma: [user <username>]
[password <password>] infiniband: [mac <MAC address>]
[mtu <MTU>]
[transport-mode datagram | connected]
[parent <ifname>]
[p-key <IPoIB P_Key>] bluetooth: [addr <bluetooth address>]
[bt-type panu|nap|dun-gsm|dun-cdma] vlan: dev <parent device (connection UUID, ifname, or MAC)>
id <VLAN ID>
[flags <VLAN flags>]
[ingress <ingress priority mapping>]
[egress <egress priority mapping>]
[mtu <MTU>] bond: [mode balance-rr () | active-backup () | balance-xor () | broadcast () |
.3ad () | balance-tlb () | balance-alb ()]
[primary <ifname>]
[miimon <num>]
[downdelay <num>]
[updelay <num>]
[arp-interval <num>]
[arp-ip-target <num>]
[lacp-rate slow () | fast ()] bond-slave: master <master (ifname, or connection UUID or name)> team: [config <file>|<raw JSON data>] team-slave: master <master (ifname, or connection UUID or name)>
[config <file>|<raw JSON data>] bridge: [stp yes|no]
[priority <num>]
[forward-delay <->]
[hello-time <->]
[max-age <->]
[ageing-time <->]
[multicast-snooping yes|no]
[mac <MAC address>] bridge-slave: master <master (ifname, or connection UUID or name)>
[priority <->]
[path-cost <->]
[hairpin yes|no] vpn: vpn-type vpnc|openvpn|pptp|openconnect|openswan|libreswan|ssh|l2tp|iodine|...
[user <username>] olpc-mesh: ssid <SSID>
[channel <->]
[dhcp-anycast <MAC address>] adsl: username <username>
protocol pppoa|pppoe|ipoatm
[password <password>]
[encapsulation vcmux|llc] tun: mode tun|tap
[owner <UID>]
[group <GID>]
[pi yes|no]
[vnet-hdr yes|no]
[multi-queue yes|no] ip-tunnel: mode ipip|gre|sit|isatap|vti|ip6ip6|ipip6|ip6gre|vti6
remote <remote endpoint IP>
[local <local endpoint IP>]
[dev <parent device (ifname or connection UUID)>] macsec: dev <parent device (connection UUID, ifname, or MAC)>
mode <psk|eap>
[cak <key> ckn <key>]
[encrypt yes|no]
[port -] macvlan: dev <parent device (connection UUID, ifname, or MAC)>
mode vepa|bridge|private|passthru|source
[tap yes|no] vxlan: id <VXLAN ID>
remote <IP of multicast group or remote address>
[local <source IP>]
[dev <parent device (ifname or connection UUID)>]
[source-port-min <->]
[source-port-max <->]
[destination-port <->] dummy: SLAVE_OPTIONS:
bridge: [priority <->]
[path-cost <->]
[hairpin yes|no] team: [config <file>|<raw JSON data>] IP_OPTIONS:
[ip4 <IPv4 address>] [gw4 <IPv4 gateway>]
[ip6 <IPv6 address>] [gw6 <IPv6 gateway>] [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection add help

14>.修改连接设置

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 80a31b55---8aae-5154a3b47040 ethernet eth0
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/sysconfig/network-scripts/ifcfg-static
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
IPADDR=172.30.1.100
PREFIX=
GATEWAY=172.30.1.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=static
UUID=c004fcc2--4e0d-a132-8e28b2582fad
DEVICE=eth2
ONBOOT=no
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static connection.autoconnect no
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static ipv4.dns 219.141.136.10
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static +ipv4.dns 219.141.140.10
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static +ipv4.dns 114.114.114.114
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static +ipv4.dns 8.8.8.8
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static -ipv4.dns 8.8.8.8
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static ipv4.addresses "172.30.1.200"
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static +ipv4.addresses 1.1.1.1/
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/sysconfig/network-scripts/ifcfg-static
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
IPADDR=172.30.1.200
PREFIX=
GATEWAY=172.30.1.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=static
UUID=c004fcc2--4e0d-a132-8e28b2582fad
DEVICE=eth2
ONBOOT=no
DNS1=219.141.136.10
DNS2=219.141.140.10
DNS3=114.114.114.114
IPADDR1=1.1.1.1
PREFIX1=
[root@node101.yinzhengjie.org.cn ~]#

15>.DNS设置,存放在/etc/resolv.conf文件中

[root@node101.yinzhengjie.org.cn ~]# cat /etc/sysconfig/network-scripts/ifcfg-static
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
IPADDR=172.30.1.200
PREFIX=
GATEWAY=172.30.1.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=static
UUID=c004fcc2--4e0d-a132-8e28b2582fad
DEVICE=eth2
ONBOOT=no
DNS1=219.141.136.10
DNS2=219.141.140.10
DNS3=114.114.114.114
IPADDR1=1.1.1.1
PREFIX1=
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static ipv4.ignore-auto-dns yes
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/sysconfig/network-scripts/ifcfg-static
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
IPADDR=172.30.1.200
PREFIX=
GATEWAY=172.30.1.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=static
UUID=c004fcc2--4e0d-a132-8e28b2582fad
DEVICE=eth2
ONBOOT=no
DNS1=219.141.136.10
DNS2=219.141.140.10
DNS3=114.114.114.114
IPADDR1=1.1.1.1
PREFIX1=
PEERDNS=no
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify static ipv4.ignore-auto-dns yes

16>.修改连接配置后,需要重新加载配置

nmcli con reload
nmcli con down “system eth0” #可被自动激活
nmcli con up “system eth0”
nmcli dev dis eth0       #禁用网卡,访止被自动激活

17>.图形工具

nm-connection-editor    #图形操作工具,需要安装Linux桌面版本

18>.字符工具

nmtui            #和Linux的setup用法类似。
nmtui-connect
nmtui-edit
nmtui-hostname

19>.nmcli实现bonding

添加bonding接口
  nmcli con add type bond con-name mybond0 ifname mybond0 mode active-backup 添加从属接口
  nmcli con add type bond-slave ifname ens7 master mybond0
  nmcli con add type bond-slave ifname ens3 master mybond0
  注:如无为从属接口提供连接名,则该名称是接口名称加类型构成 要启动绑定,则必须首先启动从属接口
  nmcli con up bond-slave-eth0
  nmcli con up bond-slave-eth1 启动绑定
  nmcli con up mybond0

20>.修改连接配置文件的名字

[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
Wired connection 80a31b55---8aae-5154a3b47040 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify Wired\ connection\ connection.id eth0
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
eth0 80a31b55---8aae-5154a3b47040 ethernet --
static c004fcc2--4e0d-a132-8e28b2582fad ethernet --
System enp0s3 3c36b8c2-334b-57c7-91b6-4401f3489c69 ethernet --
System enp0s8 00cb8299-feb9-55b6-a378-3fdc720e0bc6 ethernet --
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. root root Jul : /etc/sysconfig/network-scripts/ifcfg-enp0s8
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-eth1
-rw-r--r--. root root Aug /etc/sysconfig/network-scripts/ifcfg-lo
-rw-r--r-- root root Nov : /etc/sysconfig/network-scripts/ifcfg-static
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# nmcli connection modify Wired\ connection\ 1 connection.id eth0

三.网络组Network Teaming

1>.网络组概述

网络组:是将多个网卡聚合在一起方法,从而实现冗错和提高吞吐量

网络组不同于旧版中bonding技术,提供更好的性能和扩展性

网络组由内核驱动和teamd守护进程实现.

多种方式runner
broadcast
roundrobin
activebackup
loadbalance
lacp (implements the .3ad Link Aggregation Control Protocol) 启动网络组接口不会自动启动网络组中的port接口 启动网络组接口中的port接口总会自动启动网络组接口 禁用网络组接口会自动禁用网络组中的port接口 没有port接口的网络组接口可以启动静态IP连接 启用DHCP连接时,没有port接口的网络组会等待port接口的加入

2>.创建网络组接口 

nmcli con add type team con-name CNAME ifname INAME [config JSON]
  CNAME 连接名,INAME 接口名
  JSON 指定runner方式
  格式:'{"runner": {"name": "METHOD"}}'
  METHOD 可以是broadcast, roundrobin,activebackup, loadbalance, lacp

3>.创建port接口:

nmcli con add type team-slave con-name CNAME ifname INAME master TEAM
  CNAME 连接名
  INAME 网络接口名
  TEAM 网络组接口名
  连接名若不指定,默认为team-slave-IFACE
    nmcli dev dis INAME
    nmcli con up CNAME
    INAME 设备名 CNAME 网络组接口名或port接口

4>.网络组示例

nmcli con add type team con-name team0 ifname team0 config ‘{“runner”: {“name”: “loadbalance”}}‘ ipv4.addresses 192.168.1.100/ ipv4.method manual

nmcli con add con-name team0-eth1 type team-slave ifname eth1 master team0

nmcli con add con-name team0-eth2 type team-slave ifname eth2 master team0

nmcli con up team0

nmcli con up team0-eth1

nmcli con up team0-eth2

teamdctl team0 state

nmcli dev dis eth1

5>.实验:创建网络组

ip link

nmcli con add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"}}'

nmcli con mod team0 ipv4.addresses '192.168.0.100/24'

nmcli con mod team0 ipv4.method manual

nmcli con add con-name team0-port1 type team-slave ifname eth1 master team0

nmcli con add con-name team0-port2 type team-slave ifname eth2 master team0

teamdctl team0 state ping -I team0 192.168.0.254

nmcli dev dis eno1

teamdctl team0 state

nmcli con up team0-port1

nmcli dev dis eno2

teamdctl team0 state

nmcli con up team0-port2

teamdctl team0 state

6>.管理网络组配置文件

/etc/sysconfig/network-scripts/ifcfg-team0
DEVICE=team0
DEVICETYPE=Team
TEAM_CONFIG="{\"runner\": {\"name\": \"broadcast\"}}"
BOOTPROTO=none
IPADDR0=172.25.5.100
PREFIX0=
NAME=team0
ONBOOT=yes /etc/sysconfig/network-scripts/ifcfg-team0-eth1
DEVICE=eth1
DEVICETYPE=TeamPort
TEAM_MASTER=team0
NAME=team0-eth1
ONBOOT=yes

7>.删除网络组

nmcli connection down team0

teamdctl team0 state nmcli connection show

nmcli connectioni delete team0-eth0

nmcli connectioni delete team0-eth1

nmcli connection show

四.ethtool工具

[root@node101.yinzhengjie.org.cn ~]# ethtool eth1
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD:
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: umbg
Wake-on: d
Current message level: 0x00000007 ()
drv probe link
Link detected: yes
[root@node101.yinzhengjie.org.cn ~]#

五.mii-tools工具

[root@node101.yinzhengjie.org.cn ~]# mii-tool eth1
eth1: no autonegotiation, 1000baseT-FD flow-control, link ok
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# mii-tool eth1 -v
eth1: no autonegotiation, 1000baseT-FD flow-control, link ok
product info: Yukon 88E1011 rev
basic mode: autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
link partner: 1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

六.测试网络工具

在命令行下测试网络的连通性
显示主机名
hostname
测试网络连通性
ping
显示正确的路由表
ip route 跟踪路由
traceroute
tracepath
mtr 确定名称服务器使用
nslookup
host
dig

七.网络客户端工具

ftp,lftp:子命令:get、mget、ls、help
lftp [-p port] [-u user[,password]] SERVER lftpget URL wget [option]... [URL]...
-q 静默模式
-c 断点续传
-P /path 保存在指定目录
-O filename 保存为指定文件名,filename 为 – 时,发送至标准输出
--limit-rate= 指定传输速率,单位K,M等 links URL
--dump
--source

CentOS 7网络配置工具的更多相关文章

  1. CentOS 7 网络配置工具

    之前在CentOS 6下编辑网卡,直接使用setup工具就可以了. 但在新版的CentOS 7里,setuptool已经没有网络编辑组件了,取而代之的是NetworkManager Text User ...

  2. 【转】Linux - CentOS 7网络配置

    Linux - CentOS 7网络配置 https://blog.csdn.net/J080624/article/details/78083988   安装完VM后,需要进行网络配置.第一个目标为 ...

  3. 网络配置工具iproute2和net-tools的基本原理和基本使用方法

    这是网络程序设计课程的第一次作业的博客,由于还是小白,分享的内容都是比较基础的东西,希望看到的各位同学可以提出指导意见,必将虚心听取. 这次分享的内容是网络配置工具iproute2和net-tools ...

  4. 10.6 ip:网络配置工具

    ip命令是iproute软件包中的一个强大的网络配置工具,用于显示或管理Linux系统的路由.网络设备.策略路由和隧道.   ip [option] [object] [command] ip [选项 ...

  5. hyper-v 安装Centos及网络配置

    新安装的Centos系统默认情况下是不能上网的,需要经过相应的配置:选择对应的虚拟机,点击"虚拟交换机管理器": 设置hyper-v上的网络及分配cpu.内存.磁盘等资源. 安装C ...

  6. linux 无线网络配置工具wpa_supplicant与wireless-tools

    4.a. 介绍目前您可以使用我们提供的wireless-tools 或wpa_supplicant工具来配置无线网络.请记住重要的一点是,您对无线网络的配置是全局性的,而非针对具体的接口.wpa_su ...

  7. centos下网络配置方法(网关、dns、ip地址配置)

    本文介绍了centos网络配置的方法,centos网络配置主要包括dns.网关.IP地址: 1.IP地址配置: /etc/sysconfig/network-scripts/ifcfg-eth0 2. ...

  8. virtualbox虚拟机上安装centOS的网络配置(安装centos时选择桥接网络)

    最近接触hadoop,需要在在Linux上面开发,所以我装了一个virtualbox虚拟机,在该虚拟机上面安装了一个centOS系统.linux系统是装好了,但是网络配置却另人头疼.我主要是想让宿主机 ...

  9. virtualbox中centos虚拟机网络配置

    本文讲述的是如何在Oracle VM VirtualBox安装的CentOS虚拟机中进行网络配置,使得虚拟机可以访问宿主主机,也能访问外网,宿主主机可以访问虚拟机,虚拟机之间也可以相互访问. 在Vir ...

随机推荐

  1. PAT-2019年冬季考试-甲级 7-2 Block Reversing (25分) (链表转置)

    7-2 Block Reversing (25分)   Given a singly linked list L. Let us consider every K nodes as a block ( ...

  2. jquery checkbox全选和取消

    $("#allcheck").click(function(){ var allcheck=$('#allcheck').is(':checked'); $.each($(&quo ...

  3. vue播放mu38视频兼容谷歌ie等浏览器

    <template> <div id="id_test_video" style="width:100%; height:auto;"> ...

  4. haproxy转发真实IP给web

    1.在haproxy.cfg中加入下面参数. option forwardfor               #如果后端服务器需要获得客户端真实ip需要配置的参数,必须要放在listen模块下 2.如 ...

  5. 同类控件的统一操作(以TCHECKBOX为例)

    https://www.cnblogs.com/gaodu2003/archive/2008/12/15/1355355.html Procedure UnCheck; var i: integer; ...

  6. Linux磁盘设备基础

    free -m 查看系统内存 [root@zhang /]# free -m total       used       free     shared    buffers     cached ...

  7. Ubuntu 编译安装 nginx

    有关博客: <Windows 编译安装 nginx 服务器 + rtmp 模块>.<Ubuntu 编译安装 nginx>.<Arm-Linux 移植 Nginx> ...

  8. Vue的router-link标签

    在vue1.0版本的超链接标签还是原来的a标签,链接地址由v-link属性控制 而vue2.0版本里超链接标签由a标签被替换成了router-link标签,但最终在页面还是会被渲染成a标签的 至于为什 ...

  9. Json schema前奏 关于JSON

    目录 1. 何为 JSON 2. JSON 基本语法 3. JSON值的类型 4. 与XML比较 5. 辅助工具 1. 何为 JSON JSON( JavaScript Object Notation ...

  10. FORM表单 onclick()与onsubmit()

    FORM表单中onclick().submit()与onsubmit()的问题 最近遇到一次处理form数据的过滤,采用了button的onclick事件来检查,发现return false后表单仍然 ...