Configuring Network Configuration-RHEL7

1、查看网络状态systemctl status NetworkManager

You can use the  systemctl status NetworkManager  command to verify its current status. When NetworkManager comes up, it reads the network card configuration scripts, which are in /etc/sysconfig/network-scripts and have a name that starts with ifcfg and is followed by the name of the network card.

[[email protected] ~]#  systemctl status NetworkManager
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-06-27 14:49:51 EDT; 1min 16s ago
 Main PID: 685 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           └─685 /usr/sbin/NetworkManager --no-daemon

Jun 27 14:49:51 rhel7.com NetworkManager[685]: <info>  wpa_supplicant running
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  (enp0s3): device state change: config -> ip-config (reason ‘none‘) [50 70 0]
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  (enp0s3): device state change: ip-config -> ip-check (reason ‘none‘) [70 80 0]
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  (enp0s3): device state change: ip-check -> secondaries (reason ‘none‘) [80 90 0]
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  (enp0s3): device state change: secondaries -> activated (reason ‘none‘) [90 100 0]
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  NetworkManager state is now CONNECTED_LOCAL
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  NetworkManager state is now CONNECTED_GLOBAL
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  Policy set ‘enp0s3‘ (enp0s3) as default for IPv4 routing and DNS.
Jun 27 14:49:53 rhel7.com NetworkManager[685]: <info>  (enp0s3): Activation: successful, device activated.
Jun 27 14:49:56 rhel7.com NetworkManager[685]: <info>  startup complete
[[email protected] ~]# 

2、查看网卡配置 ip addr show

To show current network settings, you can use the  ip addr show.

[[email protected] ~]# ip addr show
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:d8:65:0a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.111/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fed8:650a/64 scope link
       valid_lft forever preferred_lft forever
[[email protected] ~]# 

3、Showing Current Connection Status:nmcli conn show

[[email protected] ~]# nmcli conn show
NAME    UUID                                  TYPE            DEVICE
enp0s3  895e0994-685c-4345-935b-a0e3af6a8cdb  802-3-ethernet  enp0s3 

After finding the name of the connection, you can use  nmcli con show  followed by the name of the connection to see all properties of the connection. Notice that this command shows many properties. #nmcli conn show enp0s3

[[email protected] ~]# nmcli conn show enp0s3
connection.id:                          enp0s3
connection.uuid:                        895e0994-685c-4345-935b-a0e3af6a8cdb
connection.interface-name:              enp0s3
connection.type:                        802-3-ethernet
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.timestamp:                   1467054591
connection.read-only:                   no
connection.permissions:
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:
connection.gateway-ping-timeout:        0
connection.metered:                     unknown
802-3-ethernet.port:                    --
802-3-ethernet.speed:                   0
802-3-ethernet.duplex:                  --
802-3-ethernet.auto-negotiate:          yes
802-3-ethernet.mac-address:             --
802-3-ethernet.cloned-mac-address:      --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu:                     auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype:            --
802-3-ethernet.s390-options:
802-3-ethernet.wake-on-lan:             1 (default)
802-3-ethernet.wake-on-lan-password:    --
ipv4.method:                            manual
ipv4.dns:
ipv4.dns-search:
ipv4.addresses:                         192.168.1.111/24
ipv4.gateway:                           192.168.1.100
ipv4.routes:
ipv4.route-metric:                      -1
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv6.method:                            auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway:                           --
ipv6.routes:
ipv6.route-metric:                      -1
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
GENERAL.NAME:                           enp0s3
GENERAL.UUID:                           895e0994-685c-4345-935b-a0e3af6a8cdb
GENERAL.DEVICES:                        enp0s3
GENERAL.STATE:                          activated
GENERAL.DEFAULT:                        yes
GENERAL.DEFAULT6:                       no
GENERAL.VPN:                            no
GENERAL.ZONE:                           --
GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/ActiveConnection/0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/Settings/0
GENERAL.SPEC-OBJECT:                    /
GENERAL.MASTER-PATH:                    --
IP4.ADDRESS[1]:                         192.168.1.111/24
IP4.GATEWAY:                            192.168.1.100
IP6.ADDRESS[1]:                         fe80::a00:27ff:fed8:650a/64
IP6.GATEWAY:
[[email protected] ~]# 

You can also use  nmcli  to show an overview of currently configured devices and the status of these devices. Type, for instance, the  nmcli dev status  command to show a list of all devices, and  nmcli dev show <devicename>  to show settings for a specific device.

[[email protected] ~]# nmcli dev show enp0s3
GENERAL.DEVICE:                         enp0s3
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         08:00:27:D8:65:0A
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     enp0s3
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.1.111/24
IP4.GATEWAY:                            192.168.1.100
IP6.ADDRESS[1]:                         fe80::a00:27ff:fed8:650a/64
IP6.GATEWAY:                            

nmcli工具还可用户直接配置、修改网络设置,但是命令用起来比较复杂,还不如直接修改配置文件或是使用nmtui命令方便。

4、使用nmtui工具配置网络

If you do not like the complicated syntax of the nmcli command line, you might like  nmtui . This is a text user interface that allows you to create network connections easily.

[[email protected] ~]# nmtui

                                            ┌─┤ NetworkManager TUI ├──┐
                                            │                         │
                                            │ Please select an option │
                                            │                         │
                                            │ Edit a connection       │
                                            │ Activate a connection   │
                                            │ Set system hostname     │
                                            │                         │
                                            │ Quit                    │
                                            │                         │
                                            │                    <OK> │
                                            │                         │
                                            └─────────────────────────┘
┌───────────────────────────┤ Edit Connection ├───────────────────────────┐
                    │                                                                         │
                    │         Profile name enp0s3__________________________________           │
                    │               Device enp0s3 (08:00:27:D8:65:0A)______________           │
                    │                                                                         │
                    │ ═ ETHERNET                                                    <Show>    │
                    │                                                                         │
                    │ ╤ IPv4 CONFIGURATION <Manual>                                 <Hide>    │
                    │ │          Addresses 192.168.1.111/24_________ <Remove>                 │
                    │ │                    <Add...>                                           │
                    │ │            Gateway 192.168.1.100____________                          │
                    │ │        DNS servers <Add...>                                           │
                    │ │     Search domains <Add...>                                           │
                    │ │                                                                       │
                    │ │            Routing (No custom routes) <Edit...>                       │
                    │ │ [ ] Never use this network for default route                          │
                    │ │                                                                       │
                    │ │ [ ] Require IPv4 addressing for this connection                       │
                    │ └                                                                       │
                    │                                                                         │
                    │ ═ IPv6 CONFIGURATION <Automatic>                              <Show>    │
                    │                                                                         │
                    │ [X] Automatically connect                                               │
                    │ [X] Available to all users                                              │
                    │                                                                         │
                    │                                                           <Cancel> <OK> │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    │                                                                         │
                    └─────────────────────────────────────────────────────────────────────────┘

The nmtui interface consists of three menu options:
■ Edit a Connection: Use this option to create new connections or edit existing connections.
■ Activate a Connection: Use this to (re)activate a connection.
■ Set System Hostname: Use this to set the hostname of your computer.

5、 The nm-connection-editor interface

这个命令是登录到图形界面,在终端执行nm-connection-editor命令,打开网络配置编辑器,能完成简单的网卡配置。

6、直接修改网络配置文件

Working on Network Configuration Files   Every connection that you create is stored as a configuration file in the directory /etc/sysconfig/network-scripts. The name of the configuration files starts with ifcfg- and is followed by the name of the network interface.

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=895e0994-685c-4345-935b-a0e3af6a8cdb
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.1.111
PREFIX=24
GATEWAY=192.168.1.100
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

Normally, there should be no need to modify these configuration files manually. If you want to, though, you can. After making changes to the configuration file, use the  nmcli con reload  command to activate the new configuration. --修改完配置文件后,使用命令nmcli conn reload使配置生效

时间: 2024-08-05 19:27:55

Configuring Network Configuration-RHEL7的相关文章

Linux - Network Configuration

Part 1: Basic Network Terminology Before setting up a network or accessing an existing network, it is important to know some key terms that are related to networking. This section explores the terms you should be aware of. Some of the terms are basic

Docker Network Configuration 高级网络配置

Network Configuration TL;DR When Docker starts, it creates a virtual interface named docker0 on the host machine. It randomly chooses an address and subnet from the private range defined by RFC 1918 that are not in use on the host machine, and assign

ubuntu开机出现waiting for network configuration

ubuntu启动时,出现waiting for network configuration,waiting up to 60 more seconds for network configuration等,进入桌面后网络图标也不见了 解决方法,首先在 /etc/network/interfaces 文件里面无关的都删去,留下lo这个 然后再到/etc/init/failsafe.conf文件里将sleep59改成5或10,sleep50意思是等待59秒

setup界面的network configuration 进不去的原因

setup界面的network configuration 进不去的原因 这个问题在百度上搜了好久都没搜到能解决的答案,最后还是自己琢磨出来的. 目前我遇进不去的原因是,因为在刚装好系统(装的是最小化的)后直接暴力装的system-config-network-tui,导致缺少依赖包,造成了点不进去. 解决办法: rpm-qa | grep 'system-config-network-tui' 查看所有安装包并过滤出网络安装包            rpm-e system-config-ne

解决 Ubuntu 开机 Waiting for 60 seconds more for network configuration

sudo vim /etc/network/interfaces, 将该文件的内容修改为如下:(也就是说删掉其他的什么auto eth0.auto wlan0) auto lo iface lo inet loopback 解决 Ubuntu 开机 Waiting for 60 seconds more for network configuration,码迷,mamicode.com 解决 Ubuntu 开机 Waiting for 60 seconds more for network co

Configuring Network Names

Configuring Network Names This page is for manual CDH installations only. Cloudera Manager users should disregard.Important: CDH requires IPv4. IPv6 is not supported.Tip: When bonding, use the bond0 IP address as it represents all aggregated links. C

Configuring Network Interface Bonding

1. Abount bonding The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical "bonded" interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide eit

Lesson5 -Linux Network Configuration

basic tasks 1.ifconfig     show ip,networkcard infomation    eth0 2.sudo dhclient      release renew IP configuration 3.sudo /etc/init.d/neworking restart             restart networking servers when you change severs configuration Configuration files

Virtual Box VM network configuration - Virtual Box VM 配置上网

Limitations: Network: company Host: DHCP Host NIC bridge: disabled Network access: limited ======================== Based on that, it might not be possible to set the VM to access Internet, & visible to host at the same time. ========================