Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ To change CentOS7 runlevel     - Linux host dual LAN transceiver package ARP problem (Linux)

- Squid proxy server configuration under Linux (Server)

- Linux, ls command to achieve (Linux)

- Ubuntu15 core CLR (Server)

- Tree Traversals Again (Programming)

- GNU Linux use diff to generate a patch with the patch (Linux)

- GNU / Linux enable Intel Rapid Start (Linux)

- PostgreSQL-XL installation and deployment (Database)

- GNU Linux system variables (sysctl configuration commands) integrated use (Linux)

- Firewall Configuration Red Hat Enterprise Linux 4 (Linux)

- Git 2.5 increase in the working tree, triangle improved workflow performance (Linux)

- Prevent security threats caused Rootkit (Linux)

- Setting Squid successful anti-hotlinking (Linux)

- Install snort intrusion detection system on Debian (Linux)

- Install minimize RHEL / CentOS 7 some things need to do (Linux)

- GlusterFS distributed storage deployment (Server)

- Preps - Print within the specified range of IP addresses (Linux)

- Java reflection mechanism explained in detail and Method.invoke explanation (Programming)

- ORA-00600: internal error code, arguments: [keltnfy-ldmInit], [46], [1], [], [], [], [], [] (Database)

- Four safety delete files under Linux tools (Linux)

 
         
  To change CentOS7 runlevel
     
  Add Date : 2018-11-21      
         
         
         
  After installing CentOS 7, a start bit powerless Tucao sense, such a big change?

One, Runlevel
First one, had been using CentOS-6.5-x86_64-minimal.iso CD image (about 400M graphics system without compact and convenient), while the smallest mirror 7 is CentOS-7.0-1406-x86_64-livecd.iso (about 700M) after the default installation is to start the graphical interface, according to the old habits start to change the command line, and found that:

[Root @ localhost ~] # cat / etc / inittab
# Inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
. # Systemd uses 'targets' instead of runlevels By default, there are two main targets:
#
# Multi-user.target: analogous to runlevel 3
# Graphical.target: analogous to runlevel 5
#
# To set a default target, run:
#
# Ln -sf / lib / systemd / system / < target name> .target /etc/systemd/system/default.target
#

Well, systemd dominate the world (it managed things a lot, we must first learn Centos7 get systemd).

[Root @ localhost ~] # ls -Xl /etc/systemd/system/*.target
. Lrwxrwxrwx 1 root root 36. 7 Yue 8 23:12 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target

We take a look at previous runlevel have become what kind?

[Root @ localhost ~] # ls -Xl / lib / systemd / system
[Root @ localhost ~] # ls -Xl /lib/systemd/system/runlevel*.target
. Lrwxrwxrwx 1 root root 15. 7 Yue 5 00:45 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx 1 root root 13. 7 Yue 5 00:45 /lib/systemd/system/runlevel1.target -.> rescue.target
lrwxrwxrwx 1 root root 17. 7 Yue 5 00:45 /lib/systemd/system/runlevel2.target -.> multi-user.target
lrwxrwxrwx 1 root root 17. 7 Yue 5 00:45 /lib/systemd/system/runlevel3.target -.> multi-user.target
lrwxrwxrwx 1 root root 17. 7 Yue 5 00:45 /lib/systemd/system/runlevel4.target -.> multi-user.target
. Lrwxrwxrwx 1 root root 16. 7 Yue 5 00:45 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx 1 root root 13. 7 Yue 5 00:45 /lib/systemd/system/runlevel6.target -.> reboot.target

Modify the default boot runlevel as multi-user (seemingly no difference between the runlevel2 3 4)

[Root @ localhost ~] # ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
[Root @ localhost ~] # ll -X /etc/systemd/system/*.target
. Lrwxrwxrwx 1 root root 37. 7 Yue 10 09:42 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target

Try not to use init 6 okay.

[Root @ localhost ~] # init 6
Connection to 192.168.150.180 closed by remote host.
Connection to 192.168.150.180 closed.

Into, easy to use. :)

Because I am from the desktop version of Linux connection Centos7 prompted became Chinese, it is required to Centos7 the root user language change it back to the original.

[Root @ localhost ~] # cp .bashrc .bashrc-back
[Root @ localhost ~] # echo 'export LANG = "en_Us.UTF-8"' >> /root/.bashrc

Two, Services

[Root @ localhost ~] # chkconfig

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'Systemctl list-dependencies [target]'.

iprdump 0: off 1: off 2: on 3: on 4: on 5: on 6: off
iprinit 0: off 1: off 2: on 3: on 4: on 5: on 6: off
iprupdate 0: off 1: off 2: on 3: on 4: on 5: on 6: off
livesys 0: off 1: off 2: off 3: on 4: on 5: on 6: off
livesys-late 0: off 1: off 2: off 3: on 4: on 5: on 6: off
netconsole 0: off 1: off 2: off 3: off 4: off 5: off 6: off
network 0: off 1: off 2: off 3: off 4: off 5: off 6: off
rhnsd 0: off 1: off 2: on 3: on 4: on 5: on 6: off
vboxadd 0: off 1: off 2: on 3: on 4: on 5: on 6: off
vboxadd-service 0: off 1: off 2: on 3: on 4: on 5: on 6: off
vboxadd-x11 0: off 1: off 2: off 3: on 4: off 5: on 6: off

 

SysV almost a back seat, and want to configure the service starting systemctl, take a look at the default startup service bar. (If you do not look grep filter, output has more than 260 rows)

 

[Root @ localhost ~] # systemctl list-unit-files | grep enabled
tmp.mount enabled
accounts-daemon.service enabled
atd.service enabled
auditd.service enabled
avahi-daemon.service enabled
bluetooth.service enabled
chronyd.service enabled
crond.service enabled
dbus-org.bluez.service enabled
dbus-org.Fedoraproject.FirewallD1.service enabled
dbus-org.freedesktop.Avahi.service enabled
dbus-org.freedesktop.NetworkManager.service enabled
dbus-org.freedesktop.nm-dispatcher.service enabled
display-manager.service enabled
dmraid-activation.service enabled
firewalld.service enabled
gdm.service enabled
getty @ .service enabled
irqbalance.service enabled
iscsi.service enabled
kdump.service enabled
libstoragemgmt.service enabled
lvm2-monitor.service enabled
mdmonitor.service enabled
microcode.service enabled
multipathd.service enabled
NetworkManager-dispatcher.service enabled
NetworkManager.service enabled
packagekit-offline-update.service enabled
postfix.service enabled
rngd.service enabled
rsyslog.service enabled
rtkit-daemon.service enabled
smartd.service enabled
spice-vdagentd.service enabled
sysstat.service enabled
systemd-readahead-collect.service enabled
systemd-readahead-drop.service enabled
systemd-readahead-replay.service enabled
tuned.service enabled
avahi-daemon.socket enabled
dm-event.socket enabled
iscsid.socket enabled
iscsiuio.socket enabled
lvm2-lvmetad.socket enabled
default.target enabled
multi-user.target enabled
remote-fs.target enabled

The default actually did not start sshd, halo! See listening port:

[Root @ localhost ~] # netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID / Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2090 / master

Sure enough, no 22, try the old way:

[Root @ localhost ~] # chkconfig sshd on
Note: Forwarding request to 'systemctl enable sshd.service'.
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'

It can be used, but the instructions are forwarded to systemctl enable sshd.service, after control of the service to use this command. Try:

Disable sshd:

[Root @ localhost ~] # systemctl disable sshd.service
rm '/etc/systemd/system/multi-user.target.wants/sshd.service'

Enable sshd:

[Root @ localhost ~] # systemctl enable sshd.service
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'

See:

[Root @ localhost ~] # systemctl list-unit-files | grep sshd.service
anaconda-sshd.service static
sshd.service enabled

[Root @ localhost ~] # netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID / Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2090 / master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2758 / sshd
tcp6 0 0 ::: 22 ::: * LISTEN 2758 / sshd

 

In fact, enable and disable services is currently "runlevel" profile directory (/etc/systemd/system/multi-user.target.wants/) years,

Establish / usr / lib / systemd / system inside the corresponding service profile soft link; disable this service is to remove soft links.
We are interested to see for himself / usr / lib / systemd / system in the file, with the syntax of the legacy of service in /etc/init.d/ script is completely different, can not be reused /etc/init.d/sshd restart the like command to start the server.

First try the old method to start the service:

[Root @ localhost ~] # service sshd start
Redirecting to / bin / systemctl start sshd.service

Toss in new ways about:

[Root @ localhost ~] # systemctl start sshd.service
[Root @ localhost ~] # systemctl stop sshd.service
[Root @ localhost ~] # systemctl restart sshd.service
[Root @ localhost ~] #

If there are no errors, it will not output any information, this ,,,, get used to it.

Third, the network
setup tool or preserved, but there are differences, there is no network configuration, more RHN (CentOS in the end the whole family is with RedHat)
[Root @ localhost ~] # setup

Well, we look at the network configuration.

[Root @ localhost ~] # cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.150.254

[Root @ localhost ~] # cat / etc / sysconfig / network
# Created by anaconda

[Root @ localhost ~] # ll / etc / sysconfig / network-scripts / ifcfg- *
-rw-r -. r-- 1 root root 298 Jul 9 00:13 / etc / sysconfig / network-scripts / ifcfg-Auto_Ethernet
-rw-r - r-- 1 root root 288 Jul 8 23:12 / etc / sysconfig / network-scripts / ifcfg-enp0s3.
-rw-r -. r-- 1 root root 254 Apr 2 23:30 / etc / sysconfig / network-scripts / ifcfg-lo

[Root @ localhost ~] # ifconfig
enp0s3: flags = 4163 < UP, BROADCAST, RUNNING, MULTICAST> mtu 1500
        inet 192.168.150.180 netmask 255.255.255.0 broadcast 192.168.150.255
        inet6 fe80 :: a00: 27ff: fe9a: a688 prefixlen 64 scopeid 0x20 < link>
        ether 08: 00: 27: 9a: a6: 88 txqueuelen 1000 (Ethernet)
        RX packets 39317 bytes 2487945 (2.3 MiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 2216 bytes 740115 (722.7 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 6 bytes 504 (504.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 6 bytes 504 (504.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[Root @ localhost ~] #

To change to change the host name:

[Root @ localhost ~] # echo "hostname cenots7.localdomain" >> / etc / sysconfig / network
[Root @ localhost ~] # reboot
Connection to 192.168.150.180 closed by remote host.
Connection to 192.168.150.180 closed.
xw @ Opt9010: ~ $ ssh root@192.168.150.180
root@192.168.150.180's password:
Last login: Thu Jul 10 10:01:09 2014
[Root @ cenots7 ~] #

See NIC configuration file:

[Root @ cenots7 ~] # cd / etc / sysconfig / network-scripts /

[Root @ cenots7 network-scripts] # cat ifcfg-Auto_Ethernet
HWADDR = 08: 00: 27: 9A: A6: 88
TYPE = Ethernet
BOOTPROTO = dhcp
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = yes
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = "Auto Ethernet"
UUID = 76304098-8f46-4185-8337-bb7f0d90423e
ONBOOT = yes

[Root @ cenots7 network-scripts] # cat ifcfg-enp0s3
HWADDR = 08: 00: 27: 9A: A6: 88
TYPE = Ethernet
BOOTPROTO = dhcp
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = yes
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = enp0s3
UUID = 66a635c2-9600-437b-8cfb-57e9569f68da
ONBOOT = no

See what's different two files:

[Root @ cenots7 network-scripts] # diff ifcfg-Auto_Ethernet ifcfg-enp0s3
14,16c14,16
< NAME = "Auto Ethernet"
< UUID = 76304098-8f46-4185-8337-bb7f0d90423e
< ONBOOT = yes
---
> NAME = enp0s3
> UUID = 66a635c2-9600-437b-8cfb-57e9569f68da
> ONBOOT = no

Like two documents MAC address, ifcfg-Auto_Ethernet ONBOOT = yes, but ifconfig showed that enp0s3, a little hard to understand.

When I look at copying KVM virtual machines often have to change the MAC address:

root @ cenots7 network-scripts] # ll /etc/udev/rules.d/
total 8
-rw-r -. r-- 1 root root 134 Jul 9 00:47 60-vboxadd.rules
-rw-r -. r-- 1 root root 352 Jul 4 00:38 98-kexec.rules

[Root @ cenots7 network-scripts] # cat /etc/udev/rules.d/98-kexec.rules
SUBSYSTEM == "cpu", ACTION == "online", PROGRAM = "/ bin / systemctl try-restart kdump.service"
SUBSYSTEM == "cpu", ACTION == "offline", PROGRAM = "/ bin / systemctl try-restart kdump.service"
SUBSYSTEM == "memory", ACTION == "add", PROGRAM = "/ bin / systemctl try-restart kdump.service"
SUBSYSTEM == "memory", ACTION == "remove", PROGRAM = "/ bin / systemctl try-restart kdump.service"

[Root @ cenots7 network-scripts] # cat /etc/udev/rules.d/60-vboxadd.rules
KERNEL == "vboxguest", NAME = "vboxguest", OWNER = "vboxadd", MODE = "0660"
KERNEL == "vboxuser", NAME = "vboxuser", OWNER = "vboxadd", MODE = "0666"

 

70-persistent-net.rules it?

NIC MAC only NIC configuration file there, once changed, I just need to change the NIC configuration file?

[Root @ cenots7 network-scripts] # grep -r "08: 00: 27: 9A: A6: 88" / etc /
/ Etc / sysconfig / network-scripts / ifcfg-enp0s3: HWADDR = 08: 00: 27: 9A: A6: 88
/ Etc / sysconfig / network-scripts / ifcfg-Auto_Ethernet: HWADDR = 08: 00: 27: 9A: A6: 88

The change NIC MAC 0800279AA688 -> 0800278C3746

After the change does not recognize the network card MAC, the test results only need to change the MAC NIC configuration file, and two configuration files must be changed job. I changed the way the DHCP fixed IP.

[Root @ cenots7 ~] # cat / etc / sysconfig / network-scripts / ifcfg-Auto_Ethernet
HWADDR = 08: 00: 27: 8C: 37: 46
# HWADDR = 08: 00: 27: 9A: A6: 88
TYPE = Ethernet
BOOTPROTO = static
IPADDR = 192.168.150.180
NETMASK = 255.255.255.0
GATEWAY = 192.168.150.254
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = no
IPV6_AUTOCONF = no
IPV6_DEFROUTE = no
IPV6_PEERDNS = no
IPV6_PEERROUTES = no
IPV6_FAILURE_FATAL = no
NAME = "Auto Ethernet"
UUID = 76304098-8f46-4185-8337-bb7f0d90423e
ONBOOT = yes

[Root @ cenots7 ~] # cat / etc / sysconfig / network-scripts / ifcfg-enp0s3
HWADDR = 08: 00: 27: 8C: 37: 46
# HWADDR = 08: 00: 27: 9A: A6: 88
TYPE = Ethernet
BOOTPROTO = static
IPADDR = 192.168.150.180
NETMASK = 255.255.255.0
GATEWAY = 192.168.150.254
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = no
IPV6_AUTOCONF = no
IPV6_DEFROUTE = no
IPV6_PEERDNS = no
IPV6_PEERROUTES = no
IPV6_FAILURE_FATAL = no
NAME = enp0s3
UUID = 66a635c2-9600-437b-8cfb-57e9569f68da
ONBOOT = no

Okay, so initially solved the basic problems.

CentOS 7 in front of a brief introduction to a slight change in the services and networks, many of the previous operation of the instruction by heart no longer applies, regardless of whether the habit, always want to accept, familiar with these changes.

Write Part time is not yet a minimal installation ISO (CentOS-7.0-1406-x86_64-Minimal.iso), first discovered later installed ifconfig, netstat, route, arp are gone, where is it?

[Root @ centos7 ~] # yum search ifconfig
......
======================== Matched: ifconfig ======================= ==
net-tools.x86_64: Basic networking tools
[Root @ centos7 ~] #

 Oh, the minimum default installation does not include these old tools, if non-use is not available, then yum install net-tools now, but I just do not want to look at how we are to manage the network.
We are going to use the ip command, two ss tools and instructions for NetworkManager nmtui, nmcli. Honestly, these tools more powerful, but really not easy to get used it.

A, ip ss command substitution ifconfig route arp netstat

1, ip command entry
ip [OPTIONS] OBJECT {COMMAND | help}
OBJECT COMMAND and can be abbreviated to one letter
ip help can be found OBJECT lists and OPTIONS, abbreviated ip h
ip < OBJECT> help See the OBJECT for help, such as ip addr help, abbreviated ip a h
ip addr view network interface address, abbreviated ip a

View Network Interface address, replace ifconfig:

[Root @ centos7 ~] # ip addr
1: lo: < LOOPBACK, UP, LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link / loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00: 00
    inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
    inet6 :: 1/128 scope host
      valid_lft forever preferred_lft forever
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global enp0s3
      valid_lft forever preferred_lft forever
    inet6 fe80 :: a00: 27ff: fe15: 35d2 / 64 scope link
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #

Network interface statistics

[Root @ centos7 ~] # ip -s link
1: lo: < LOOPBACK, UP, LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link / loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00: 00
    RX: bytes packets errors dropped overrun mcast
    000000
    TX: bytes packets errors dropped carrier collsns
    000000
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    RX: bytes packets errors dropped overrun mcast
    8,135,366,131,454,000,456
    TX: bytes packets errors dropped carrier collsns
    64629724410000

2, ip route Display and setting routing

Displays the routing table

[Root @ centos7 ~] # ip route
default via 192.168.150.254 dev enp0s3 proto static metric 1024
192.168.150.0/24 dev enp0s3 proto kernel scope link src 192.168.150.110

Ugly, what format (it shows the default gateway and LAN routing, two lines of content are not compatible):

[Root @ centos7 tmp] # ip route | column -t
default via 192.168.150.254 dev enp0s3 proto static metric 1024
192.168.150.0/24 dev enp0s3 proto kernel scope link src 192.168.150.110

Add a static route

[Root @ centos7 ~] # ip route add 10.15.150.0/24 via 192.168.150.253 dev enp0s3
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip route | column -t
default via 192.168.150.254 dev enp0s3 proto static metric 1024
10.15.150.0/24 via 192.168.150.253 dev enp0s3 proto static metric 1
192.168.150.0/24 dev enp0s3 proto kernel scope link src 192.168.150.110
[Root @ centos7 ~] #
[Root @ centos7 ~] # ping 10.15.150.1
PING 10.15.150.1 (10.15.150.1) 56 (84) bytes of data.
64 bytes from 10.15.150.1: icmp_seq = 1 ttl = 63 time = 1.77 ms
64 bytes from 10.15.150.1: icmp_seq = 1 ttl = 63 time = 1.08 ms
64 bytes from 10.15.150.1: icmp_seq = 1 ttl = 63 time = 1.57 ms
^ C

Delete static routes need only to add replace del, or simply just write the destination network

[Root @ centos7 ~] # ip route del 10.15.150.0/24
[Root @ centos7 ~] #

However, changing the ip route command routing can not be saved, restart gone.
Set up a permanent static routing method RHEL official website several documents speak, only one successfully tested:

[Root @ centos7 ~] #echo "10.15.150.0/24 via 192.168.150.253 dev enp0s3"> / etc / sysconfig / network-scripts / route-enp0s3

Restart the computer, and then enable or disable the device enp0s3 to take effect,
Note: / etc / sysconfig / static-routes, / etc / sysconfig / network configuration files are not easy to use.

3, with ip neighbor replace the arp -n

[Root @ centos7 ~] # ip nei
192.168.150.254 dev enp0s3 lladdr b8: a3: 86: 37: bd: f8 STALE
192.168.150.100 dev enp0s3 lladdr 90: b1: 1c: 94: a1: 20 DELAY
192.168.150.253 dev enp0s3 lladdr 00: 09: 0f: 85: 86: b9 STALE

4, instead of using netstat ss
Correspondence netstat -ant

[Root @ centos7 ~] # ss -ant
State Recv-Q Send-Q Local Address: Port Peer Address: Port
LISTEN 0 100 127.0.0.1:25 *: *
LISTEN 0 128 *: 22 *: *
ESTAB 0 0 192.168.150.110:22 192.168.150.100:53233
LISTEN 0 100 :: 1: 25 ::: *
LISTEN 0 128 ::: 22 ::: *

Correspondence netstat -antp

[Root @ centos7 tmp] # ss -antp
State Recv-Q Send-Q Local Address: Port Peer Address: Port
LISTEN 0 100 127.0.0.1:25 *: *
users: (( "master", 1817,13))
LISTEN 0 128 *: 22 *: *
users: (( "sshd", 1288,3))
ESTAB 0 0 192.168.150.110:22 192.168.150.100:59413
users: (( "sshd", 2299,3))
LISTEN 0 100 :: 1: 25 ::: *
users: (( "master", 1817,14))
LISTEN 0 128 ::: 22 ::: *
users: (( "sshd", 1288,4))
[Root @ centos7 tmp] #

Looked really uncomfortable, no matter how wide the terminal screen, users: part will be off to the next line, in fact, is in line.

What format, content and tidy, but the header line string:

[Root @ centos7 tmp] # ss -antp | column -t
State Recv-Q Send-Q Local Address: Port Peer Address: Port
LISTEN 0 100 127.0.0.1:25 *: * users: (( "master", 1817,13))
LISTEN 0 128 *: 22 *: * users: (( "sshd", 1288,3))
ESTAB 0 0 192.168.150.110:22 192.168.150.100:59413 users: (( "sshd", 2299,3))
LISTEN 0 100 :: 1: 25 ::: * users: (( "master", 1817,14))
LISTEN 0 128 ::: 22 ::: * users: (( "sshd", 1288,4))

5, the old network and ifcfg script file
Centos7 start, a network of NetworkManager service is responsible for the management, with respect to the old /etc/init.d/network script, NetworkManager is dynamic, event-driven network management services. Old /etc/init.d/network and ifup, ifdown still exist, but in a standby state, namely: NetworkManager is running, in most cases these script calls NetworkManager to complete the network configuration tasks; NetworkManager it has run, these script according to the old tradition of managing the network.

[Root @ centos7 ~] # /etc/init.d/network start
Starting network (via systemctl): [OK]

Note (via systemctl).

6, network configuration file:
/ Etc / sysconfig / network said is a global setting, the default which had nothing
/ Etc / hostname with the hostname modified nmtui, host name saved here
/etc/resolv.conf save DNS settings without manual change, DNS nmtui set up inside will appear here
/ Etc / sysconfig / network-scripts / ifcfg file connection configuration information
/ Etc / NetworkManager / system-connections / VPN, mobile broadband, PPPoE connection

Two, nmtui configure basic network connectivity
nmtui belong curses-based text user interface (text user interface), similar to the setup CentOS6 tool, but can only edit the connection, enable / disable the connection, change the host name. After the system installed early may be the first use nmtui configure the network, very convenient.
Figure it, you can use the tab key to jump function or the cursor keys, with a space or carriage return execution. Each sub-function is complete, quit or canceled directly back to the command line (inconvenient to try nmtui help, have direct access method).

At the command line to run nmtui

Add a connection, a connection support is very rich ah, there is WiFi yet. But vpn Where? Oh, nmtui is not yet supported.

Edit Connection.

I wish to be allocated where to jump, where, if you do not like this enp0s3 connection name, you can get rid of the Profile name, would say later renamed benefits.

Note that a space can only edit box

Enable / disable the connection when a remote connection can try to perform at < Deactivate>, then tears it

Change the host name, changed after the restart to be effective, do not want to restart back to the command line hostname < your host name>, log off and log enough.

Three, nmcli and other network settings
nmcli functions to powerful, more complex

[Root @ CentOS7 ~] # nmcli help
Usage: nmcli [OPTIONS] OBJECT {COMMAND | help}

OPTIONS
  -t [erse] terse output
  -p [retty] pretty output
  -m [ode] tabular | multiline output mode
  -f [ields] < field1, field2, ...> | all | common specify fields to output
  -e [scape] yes | no escape columns separators in values
  -n [ocheck] do not check nmcli and NetworkManager versions
  -a [sk] ask for missing parameters
  -w [ait] < seconds> set timeout waiting for finishing operations
  -v [ersion] show program version
  -h [elp] print this help

OBJECT
  g [eneral] NetworkManager's general status and operations
  n [etworking] overall networking control
  r [adio] NetworkManager radio switches
  c [onnection] NetworkManager's connections
  d [evice] devices managed by NetworkManager

OBJECT COMMAND and can also be used with the full name referred to, at least you can use only one letter, it is recommended to use the first three letters. OBJECT which we usually use the most is the connection and device, here simply to distinguish between connection and device.

device called a network interface is the physical device
connection is connected, the emphasis on logic settings
A plurality of connection can be applied to the same device, but at the same time enable only one connection.
The advantage is that for a network interface, we can set up multiple network connections, such as a static IP and dynamic IP, and then as needed up the appropriate connection.

The article said, / etc / udev / rules.d / 70-persistent-net.rules file is not a newly added card NetworkManager automatically identified. We now try to Virtualbox virtual machine to add a second network card, start the virtual machine can directly see and enter into force.

[Root @ centos7 ~] # nmcli con show
NAME UUID TYPE DEVICE
Wired connection 1 0c451785-b098-4c5c-994d-9107171b439d 802-3-ethernet enp0s8
enp0s3 295e1841-0ff3-4db9-8800-4e25fc2944da 802-3-ethernet enp0s3

"Wired connection 1" is a new network connection, the corresponding network interface called enp0s8;
"Enp0s3" is the first network connection, and the default network interface of the same name.

We can use the two connectors into nmtui familiar name (nmcli can, but more trouble oh). Change over to see the connection:

[Root @ centos7 ~] # nmcli con show
NAME UUID TYPE DEVICE
eth1 0c451785-b098-4c5c-994d-9107171b439d 802-3-ethernet enp0s8
eth0 295e1841-0ff3-4db9-8800-4e25fc2944da 802-3-ethernet enp0s3

So much more comfortable!

See if the device:

[Root @ centos7 ~] # nmcli dev show enp0s3
GENERAL.DEVICE: enp0s3
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 08: 00: 27: 15: 35: D2
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]: ip = 192.168.150.110/24, gw = 192.168.150.254
IP4.DNS [1]: 192.168.150.254
IP6.ADDRESS [1]: ip = fe80 :: a00: 27ff: fe15: 35d2 / 64, gw = ::
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli dev show enp0s8
GENERAL.DEVICE: enp0s8
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 08: 00: 27: 98: D1: B7
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: eth1
GENERAL.CON-PATH: / org / freedesktop / NetworkManager / ActiveConnection / 3
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS [1]: ip = 10.0.3.15/24, gw = 10.0.3.2
IP4.DNS [1]: 10.0.3.2
IP6.ADDRESS [1]: ip = fe80 :: a00: 27ff: fe98: d1b7 / 64, gw = ::
[Root @ centos7 ~] #

But try to use the connection name check equipment?

[Root @ centos7 ~] # nmcli dev show eth0
Error: Device 'eth0' not found.

Check the connection is the same mistake with the device name:

[Root @ centos7 ~] # nmcli con show enp0s3
Error: enp0s3 - no such connection profile.

This time can see it? Understand the difference and connection devices, which help in some instructions and some parameters required connection, and some need to device, it will not be confused.

Note that, enp0s3 device corresponds to the connection name eth0, but the corresponding ifcfg file is not renamed, we try to change to change, to change before the first backup the original configuration file to a different directory (note, not backing up to network-scripts directory !).

[Root @ centos7 network-scripts] # cat ifcfg-enp0s3
TYPE = Ethernet
BOOTPROTO = none
DEFROUTE = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = no
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = eth0
UUID = 295e1841-0ff3-4db9-8800-4e25fc2944da
ONBOOT = yes
IPADDR0 = 192.168.150.110
PREFIX0 = 24
GATEWAY0 = 192.168.150.254
DNS1 = 192.168.150.254
HWADDR = 08: 00: 27: 15: 35: D2
[Root @ centos7 network-scripts] #
[Root @ centos7 network-scripts] # cp ifcfg-enp0s3 / root /
[Root @ centos7 network-scripts] # mv ifcfg-enp0s3 ifcfg-eth0
[Root @ centos7 network-scripts] #
[Root @ centos7 network-scripts] # systemctl restart network
[Root @ centos7 network-scripts] #

No problem, the configuration file was renamed successfully, obsessive-compulsive disorder another victory, yeah!
We can also see, ifcfg-eth0 there will be no parameters specified equipment enp0s3, unique device enp0s3 corresponding to the MAC address (HWADDR 08: 00: 27: 15: 35: D2).

Now try to increase for a new network interface enp0s8 connection, the existing connection is eth1:

[Root @ centos7 network-scripts] # cat ifcfg-eth1
HWADDR = 08: 00: 27: 98: D1: B7
TYPE = Ethernet
BOOTPROTO = dhcp
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = yes
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = eth1
UUID = 0c451785-b098-4c5c-994d-9107171b439d
ONBOOT = yes

Ah, either automatically obtain the IP.

We create a new connection eth1-1, assign a fixed IP, with nmtui can easily create


[Root @ centos7 ~] # nmcli con show
NAME UUID TYPE DEVICE
eth1-1 ef5c3fbc-f07a-4d6e-9f4d-83f239ffc2e9 802-3-ethernet -
eth1 0c451785-b098-4c5c-994d-9107171b439d 802-3-ethernet enp0s8
eth0 295e1841-0ff3-4db9-8800-4e25fc2944da 802-3-ethernet enp0s3
Just added a connection, the other has not changed.
We start a new connection eth1-1
[Root @ centos7 ~] # nmcli con up eth1-1
Connection successfully activated (D-Bus active path: / org / freedesktop / NetworkManager / ActiveConnection / 2)
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli con show
NAME UUID TYPE DEVICE
eth1-1 ef5c3fbc-f07a-4d6e-9f4d-83f239ffc2e9 802-3-ethernet enp0s8
eth1 0c451785-b098-4c5c-994d-9107171b439d 802-3-ethernet -
eth0 295e1841-0ff3-4db9-8800-4e25fc2944da 802-3-ethernet enp0s3
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s8
IP4.ADDRESS [1]: ip = 10.0.3.110/24, gw = 10.0.3.2

"Nmcli -t -f IP4.ADDRESS dev show enp0s8" is a script-friendly way to display network interface information.
We can now clearly see the connection eth1-1 up after, eth1-1 occupied DEVICE originally occupied by the eth1 enp0s8, and the IP address has been assigned the 10.0.3.110/24.

[Root @ centos7 network-scripts] # cat ifcfg-eth1-1
TYPE = Ethernet
BOOTPROTO = none
IPADDR0 = 10.0.3.110
PREFIX0 = 24
GATEWAY0 = 10.0.3.2
DNS1 = 10.0.3.2
DEFROUTE = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = no
NAME = eth1-1
UUID = ef5c3fbc-f07a-4d6e-9f4d-83f239ffc2e9
DEVICE = enp0s8
ONBOOT = yes

ifcfg-eth1-1 file HWADDR no parameters, but more than a DEVICE parameter equal enp0s8, you can compare the ifcfg-eth1 to see the difference between what.
Profile connection ifcfg- *, DEVICE can be used to specify the device name, you can also specify the MAC address of the device with HWADDR, the final results are the same point to a device (a network interface).

We try to increase the connection trial nmcli:

[Root @ centos7 ~] # nmcli con add con-name eth1-2 ifname enp0s8 type ethernet ip4 10.0.3.120/24 gw4 10.0.3.2
Connection 'eth1-2' (468815f5-ce97-43bd-904a-3078e2e59fec) successfully added.
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli con show
NAME UUID TYPE DEVICE
eth1-1 ef5c3fbc-f07a-4d6e-9f4d-83f239ffc2e9 802-3-ethernet enp0s8
eth1 0c451785-b098-4c5c-994d-9107171b439d 802-3-ethernet -
eth0 295e1841-0ff3-4db9-8800-4e25fc2944da 802-3-ethernet enp0s3
eth1-2 468815f5-ce97-43bd-904a-3078e2e59fec 802-3-ethernet -
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli con up eth1-2
Connection successfully activated (D-Bus active path: / org / freedesktop / NetworkManager / ActiveConnection / 3)
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli con show
NAME UUID TYPE DEVICE
eth1-1 ef5c3fbc-f07a-4d6e-9f4d-83f239ffc2e9 802-3-ethernet -
eth1 0c451785-b098-4c5c-994d-9107171b439d 802-3-ethernet -
eth0 295e1841-0ff3-4db9-8800-4e25fc2944da 802-3-ethernet enp0s3
eth1-2 468815f5-ce97-43bd-904a-3078e2e59fec 802-3-ethernet enp0s8
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s8
IP4.ADDRESS [1]: ip = 10.0.3.120/24, gw = 10.0.3.2
[Root @ centos7 ~] #

Look at the new ifcfg file:

[Root @ centos7 network-scripts] # cat ifcfg-eth1-2
TYPE = Ethernet
BOOTPROTO = none
IPADDR0 = 10.0.3.120
PREFIX0 = 24
GATEWAY0 = 10.0.3.2
DEFROUTE = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = yes
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = eth1-2
UUID = 468815f5-ce97-43bd-904a-3078e2e59fec
DEVICE = enp0s8
ONBOOT = yes
[Root @ centos7 network-scripts] #

The connection is now up eth1-2, network interface enp0s8 of IP is 10.0.3.120
If you re-up connection eth1-1, nmcli con up eth1-1, the IP network interface enp0s8 became 10.0.3.110
If you re-up connection eth1, nmcli con up eth1, the IP network interface enp0s8 automatically returned to the original value of 10.0.3.15

Therefore, a different set of network interface connection, you can quickly switch between different network configurations, this is really full of powerful.

Edit Connections
After editing with nmtui connection, ifcfg file will have a corresponding change; manually modified ifcfg, nmtui can also be seen.
However, whether directly or by nmtui modify ifcfg file, you want the new configuration to take effect, we need to load up connection profile and re-connect.

For example, we edit ifcfg-eth1-1, change the IP 10.0.3.111, and then perform nmcli con reload or nmcli con load / etc / sysconfig / network-scripts / ifcfg-eth1-1
The results are as follows:

[Root @ centos7 ~] # nmcli con load / etc / sysconfig / network-scripts / ifcfg-eth1-1
[Root @ centos7 ~] # nmcli con up eth1-1
Connection successfully activated (D-Bus active path: / org / freedesktop / NetworkManager / ActiveConnection / 2)
[Root @ centos7 ~] # ip addr show enp0s8
3: enp0s8: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 98: d1: b7 brd ff: ff: ff: ff: ff: ff
    inet 10.0.3.111/24 brd 10.0.3.255 scope global enp0s8
      valid_lft forever preferred_lft forever
    inet6 fe80 :: a00: 27ff: fe98: d1b7 / 64 scope link
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #

The new IP address into effect.

BONUS: If you have a physical WLAN, nmcli can view the wifi, Chou Chou, the fun, right? (Example from nmcli-examples (5) man page, command: man 5 nmcli-examples)

$ Nmcli device wifi list

          * SSID MODE CHAN RATE SIGNAL BARS SECURITY
              netdatacomm_local Infra 6 54 MB / s 37 WEP
          * F1 Infra 11 54 MB / s 98 WPA1
              LoremCorp Infra 1 54 MB / s 62 WPA2 802.1X
              Internet Infra 6 54 MB / s 29 WPA1
              HPB110a.F2672A Ad-Hoc 6 54 MB / s 22 -

Since many basic configuration can be used nmtui do, and often set once is enough, when nmcli command line with other powerful functions and then check it, there is not much talk about it.

reference:
https://access.RedHat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/index.html (written in this document it ,,,, alas ...)
nmcli-examples (5) man page - Gives examples of nmcli commands.
ip (8) man page - Describes the ip utility's command syntax.
nmcli (1) man page - Describes NetworkManager's command-line tool.

A, nmtui manually add IP

Look at the current network device IP, in order to streamline the command output, the instruction can be more complicated:

[Root @ CentOS7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s3
IP4.ADDRESS [1]: ip = 192.168.150.110/24, gw = 192.168.150.254
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip addr show enp0s3 scope global
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global enp0s3
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #
[Root @ centos7 ~] # cat / etc / sysconfig / network-scripts / ifcfg-eth0
......
IPADDR0 = 192.168.150.110
PREFIX0 = 24
GATEWAY0 = 192.168.150.254
DNS1 = 192.168.150.254
HWADDR = 08: 00: 27: 15: 35: D2
IPADDR1 = 192.168.150.111
PREFIX1 = 24
[Root @ centos7 ~] #

The new IP has been added to the ifcfg-eth0, keywords original address keyword IPADDR0, PREFIX0, the new address is IPADDR1, PREFIX1.

[Root @ centos7 ~] # nmcli con load / etc / sysconfig / network-scripts / ifcfg-eth0
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s3
IP4.ADDRESS [1]: ip = 192.168.150.110/24, gw = 192.168.150.254
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip addr show enp0s3 scope global
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global enp0s3
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #

After load connection, NetworkManager does not know the new IP, new IP does not appear in the ip addr show.

[Root @ centos7 ~] # systemctl restart network
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s3
IP4.ADDRESS [1]: ip = 192.168.150.110/24, gw = 192.168.150.254
IP4.ADDRESS [2]: ip = 192.168.150.111/24, gw = 192.168.150.254
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip addr show enp0s3 scope global
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global enp0s3
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # ping 192.168.150.111
PING 192.168.150.111 (192.168.150.111) 56 (84) bytes of data.
From 192.168.150.110 icmp_seq = 1 Destination Host Unreachable
From 192.168.150.110 icmp_seq = 2 Destination Host Unreachable
......
[Root @ centos7 ~] #

After restarting network services, NetworkManager aware of the new IP, new IP but still no effect.

[Root @ centos7 ~] # nmcli dev connect enp0s3
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s3
IP4.ADDRESS [1]: ip = 192.168.150.110/24, gw = 192.168.150.254
IP4.ADDRESS [2]: ip = 192.168.150.111/24, gw = 192.168.150.254
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip addr show enp0s3 scope global
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global enp0s3
      valid_lft forever preferred_lft forever
    inet 192.168.150.111/24 brd 192.168.150.255 scope global secondary enp0s3
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # ping 192.168.150.111
PING 192.168.150.111 (192.168.150.111) 56 (84) bytes of data.
64 bytes from 192.168.150.111: icmp_seq = 1 ttl = 64 time = 0.039 ms
64 bytes from 192.168.150.111: icmp_seq = 2 ttl = 64 time = 0.079 ms
......
[Root @ centos7 ~] #

Reconnect the device enp0s3, new IP into effect. Note: do not need to disconnect the device (nmcli dev disconnect enp0s3), disconnect the device, then ssh disconnected immediately. The process of reconnecting device, ssh is not disconnected.

After nmtui add IP, requires:
nmcli con load / etc / sysconfig / network-scripts / ifcfg-eth0
nmcli dev connect enp0s3

Second, manually add IP to ifcfg-eth0

Add ifcfg-eth0 configuration file by hand following two lines:
IPADDR2 = 192.168.150.112
PREFIX2 = 24

After the first execution nmcli con load / etc / sysconfig / network-scripts / ifcfg-eth0, in nmtui you can see the new IP. (You can also simply use nmcli con reload, reload the difference between brain and load themselves up with it.)
After then perform nmcli dev connect enp0s3, IP 192.168.150.112 only force.

After manually adding IP to ifcfg-eth0, it requires:
nmcli con load / etc / sysconfig / network-scripts / ifcfg-eth0 or nmcli con reload
nmcli dev connect enp0s3

Third, use ip addr add command to add / remove IP, effective immediately, the restart is not retained.

Online add IP:

[Root @ centos7 ~] # ip addr add 192.168.150.113/24 dev enp0s3
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s3
IP4.ADDRESS [1]: ip = 192.168.150.110/24, gw = 192.168.150.254
IP4.ADDRESS [2]: ip = 192.168.150.111/24, gw = 192.168.150.254
IP4.ADDRESS [3]: ip = 192.168.150.112/24, gw = 192.168.150.254
IP4.ADDRESS [4]: ip = 192.168.150.113/24, gw = 192.168.150.254
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip addr show enp0s3 scope global
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global enp0s3
      valid_lft forever preferred_lft forever
    inet 192.168.150.111/24 brd 192.168.150.255 scope global secondary enp0s3
      valid_lft forever preferred_lft forever
    inet 192.168.150.112/24 brd 192.168.150.255 scope global secondary enp0s3
      valid_lft forever preferred_lft forever
    inet 192.168.150.113/24 scope global secondary enp0s3
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # ping 192.168.150.113
PING 192.168.150.113 (192.168.150.113) 56 (84) bytes of data.
64 bytes from 192.168.150.113: icmp_seq = 1 ttl = 64 time = 0.098 ms
64 bytes from 192.168.150.113: icmp_seq = 2 ttl = 64 time = 0.255 ms
......

/ Etc / sysconfig / network-scripts / ifcfg-eth0 configuration file is not 192.168.150.113, so after the restart of the IP will not be retained.

Deleted online IP:

[Root @ centos7 ~] # ip addr del 192.168.150.113/24 dev enp0s3
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s3
IP4.ADDRESS [1]: ip = 192.168.150.110/24, gw = 192.168.150.254
IP4.ADDRESS [2]: ip = 192.168.150.111/24, gw = 192.168.150.254
IP4.ADDRESS [3]: ip = 192.168.150.112/24, gw = 192.168.150.254
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip addr show enp0s3 scope global
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global enp0s3
      valid_lft forever preferred_lft forever
    inet 192.168.150.111/24 brd 192.168.150.255 scope global secondary enp0s3
      valid_lft forever preferred_lft forever
    inet 192.168.150.112/24 brd 192.168.150.255 scope global secondary enp0s3
      valid_lft forever preferred_lft forever

Fourth, the use of sub-connection configuration file ifcfg - *: n

Sub connection profile is Centos6 commonly used method, namely: if the current NIC configuration file ifcfg-eth0, then ligated profile for ifcfg-eth0: 1, and the file needs to specify the DEVICE = eth0: 1, IPADDR = < The new IP address>.
We try Centos7 if also supported. In theory, it should not be supported because Centos7 network connection profiles (ie ifcfg- *) in, DEVICE keyword already has a new definition, which we on the articles says "Device." Refer to the previous pages.

First comment out ifcfg-eth0 other addresses, copying ifcfg-eth0 to ifcfg-eth0: 1, edit the ifcfg-eth0: 1, DEVICE to eth0: 1, IP is set to 192.168.150.119, then nmcli con reload, nmcli dev con enp0s3


Copy the code
[Root @ centos7 ~] # cat / etc / sysconfig / network-scripts / ifcfg-eth0
TYPE = Ethernet
BOOTPROTO = none
DEFROUTE = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = no
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = eth0
UUID = 295e1841-0ff3-4db9-8800-4e25fc2944da
ONBOOT = yes
IPADDR0 = 192.168.150.110
PREFIX0 = 24
GATEWAY0 = 192.168.150.254
DNS1 = 192.168.150.254
HWADDR = 08: 00: 27: 15: 35: D2
# IPADDR1 = 192.168.150.111
# PREFIX1 = 24
# IPADDR2 = 192.168.150.112
# PREFIX2 = 24

[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # cat / etc / sysconfig / network-scripts / ifcfg-eth0: 1
TYPE = Ethernet
BOOTPROTO = none
DEFROUTE = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = no
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
NAME = eth0: 1
DEVICE = eth0: 1
UUID = 295e1841-0ff3-4db9-8800-4e25fc2944da
ONBOOT = yes
IPADDR0 = 192.168.150.119
PREFIX0 = 24
GATEWAY0 = 192.168.150.254
DNS1 = 192.168.150.254
HWADDR = 08: 00: 27: 15: 35: D2
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli con reload
[Root @ centos7 ~] # nmcli dev connect enp0s3
[Root @ centos7 ~] #
[Root @ centos7 ~] # nmcli -t -f IP4.ADDRESS dev show enp0s3
IP4.ADDRESS [1]: ip = 192.168.150.110/24, gw = 192.168.150.254
[Root @ centos7 ~] #
[Root @ centos7 ~] #
[Root @ centos7 ~] # ip addr show enp0s3 scope global
2: enp0s3: < BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link / ether 08: 00: 27: 15: 35: d2 brd ff: ff: ff: ff: ff: ff
    inet 192.168.150.110/24 brd 192.168.150.255 scope global eth0: 1
      valid_lft forever preferred_lft forever
[Root @ centos7 ~] #

We can see the ifcfg-eth0: 1 in the new IP does not take effect.

V. Summary
IP ip addr show shown to be effective.
ip addr add lines can add IP, with immediate effect, but that is lost to restart.
ip addr del online can delete IP, with immediate effect, but that is lost to restart.
Ligated (ifcfg - *: n) has been invalidated.
nmtui ifcfg-eth0 file and edit the effect is basically the same, can not take effect immediately, you must load the network connection and re-connect equipment, namely:
nmcli con load / etc / sysconfig / network-scripts / ifcfg-eth0 or nmcli reload
nmcli dev connect enp0s3
     
         
         
         
  More:      
 
- Build the first ASP.NET 5 Web project in Mac OS X Yosemite 10.10.3 (Server)
- File permissions under Linux (Linux)
- Using the Android interface in Parcelable (Programming)
- Linux Basics Tutorial: Combining awk delete data before the specified date hdfs (Linux)
- CentOS 6.5 set under Oracle 12c at startup (Database)
- Ubuntu 32 compile Android 4.0.4 Problems (Linux)
- Linux stand-alone OGG synchronous Oracle 11g DB test (Database)
- Binding multiple network cards in Linux using command nmcli (Linux)
- High-performance open-source http accelerator Varnish introduce (Server)
- Kernel compile under Debian (Linux)
- Introduction to Linux system process monitoring tools (Linux)
- BCP importing and exporting large amounts of data Practice (Database)
- Linux asynchronous read documents by AIO (Programming)
- Struts2 Result Types (Programming)
- Oracle Data Guard LOG_ARCHIVE_DEST_n optional attribute parameters (Database)
- OGG-01496 OGG-01031 Error Resolution (Database)
- MySQL configuration file my.cnf increase the log file parameter error (Database)
- Ubuntu 14.04 compile, install, configure, the latest development version GoldenDict (Linux)
- How to fix apt-get update can not add a new CD-ROM error (Linux)
- Performance Optimization: Using Ramlog transfer log files to memory (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.