Linux oracle настроить сетевой интерфейс

Use NetworkManager and IP Command on Oracle Linux

In this tutorial you work with the Oracle Linux CLI utilities, nmcli and ip , to monitor and manage network devices and connections.

The lab’s intent is to introduce you to these utilities and practice using their common features to simulate a work environment. Not all of the features are presented. The lab runs in a virtualized environment and therefore limits what can be presented and practiced.

Background

Linux handles network communications through software configuration files and the physical networking devices in your system. Each physical network device has an associated configuration file, named ifcfg- , located in the /etc/sysconfig/network-scripts directory.

NetworkManager includes a command-line utility, nmcli , which you can use to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.

The ip is another utility for displaying and manipulating network devices, network routing, and tunnels.

Objectives

  • View network status information using command line utilities: nmcli and ip .
  • Change the system host name
  • Change the logging level
  • View connection information
  • Add, edit and delete a connection profile
  • View device status information

What Do You Need?

A client system with Oracle Linux installed with at least three disk devices.

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

Run nmcli general Object Commands

You use nmcli general object commands to show overall network status and to perform operations.

    Run the command nmcli help and note the available options.

  • -t|—terse : This mode is designed and suitable for script processing.
  • -p|—pretty : This mode produces easily readable output with a header.
  • -m|—mode tabular|multiline : This mode produces output in table format or on multiple lines.

Refer to the nmcli man page for a description for all available options.

Note: The general option provides four command arguments: status , hostname , permissions , and logging .

systemctl stop NetworkManager 
systemctl start NetworkManager 

This argument reports the system hostname. You can also use nmcli general hostname to change the name of the host.

nmcli general hostname myhost 
nmcli general hostname ol-server 
nmcli general permissions 

The output shows all premissions are set to yes , which means that you can enable and disable networking and modify all connections and settings.

Use the logging argument to view and change NetworkManager logging levels and domains. Without any arguments, the current logging level and domains are shown. In this case, the logging level is INFO for all domains. Refer to the NetworkManager.conf man page for information about logging levels and domain descriptions.

nmcli general logging level DEBUG domains IP4 
nmcli general logging level INFO domains ALL 

Run nmcli networking Object Commands.

You use the nmcli networking object to manage networking connectivity and view networking status.

Читайте также:  Лицензирование сервера 1с линукс

    Run the nmcli networking help command.

  • The command nmcli networking off disables networking to all enabled devices.
  • The command nmcli networking on enables networking to all enabled devices.
  • Include the check argument.
  • Without the check argument, the command displays the most recent known connectivity state without re-checking.
nmcli networking connectivity check 

Connectivity state full means the host is connected to a network and has full access to the Internet.

Run nmcli radio Object Commands

Use nmcli radio object commands to manage wireless networking.

    Run the command nmcli radio help .

Note: The three available command options: all , wifi , wwan . Each command has two arguments.

Run nmcli connection Object Commands

Use the nmcli connection object to start, stop, and manage network connections.

    Run the command nmcli connection help command.

connection objects

Run the command nmcli connection show to list all the connection profiles.

nmcli connection show --active 
ls -l /etc/sysconfig/network-scripts/ | grep ens 
  • Create a configuration profile for ens5 and bring the device online. By design, NetworkManager allows a single device to have multiple connections or profiles. These profiles allow for different network configurations such as DHCP or static IP address assignments.
    1. Obtain the Private IP of the second VNIC device attached to your lab instance.
      1. Return to the Cloud Console >Compute >Instances page. compute instances
      2. In the list of names, click the link to your instance (ol-server) to open its details page.
      3. Scroll down the details page to the Resources section, and then click Attached VNICs from the list to view the VNICs. attached vnics
      4. From the list of VNICs, click the link to vnic-2 to view details about the VNIC.
      5. In the Primary IP section of the page, copy the Private IP Address (e.g. 10.0.0.155) and return the the terminal window. private ip
    2. Run the command nmcli connection add type ethernet con-name ens5 ifname ens5 ip4 , for example: 10.0.0.155/24 to create the a configuration profile for ens5 .

      nmcli connection add type ethernet con-name ens5 ifname ens5 ip4 10.0.0.155/24 

      The configuration defines a static IP address assignment and presents the ip4 address in CIDR notation. NetworkManager writes these values in a /etc/sysconfig/network-scripts/ifcfg- file to keep the configuration persistent after reboots.

      cat /etc/sysconfig/network-scripts/ifcfg-ens5 

      The command shows the new connection profile created for ens5 . NetworkManager allows the use of abbreviations for nmcli commands.

      The -c sends out only three packets, and then -I parameter ensures the packets go out on the ens5 interface.

      nmcli connection show id ens5 | grep autoconnect 

      You use the ip utility to configure network interfaces. You need elevated privileges to use the ip utility. It is important to note that any network changes made using the ip command do not persist across system reboots.

      In the following tasks, you continue to use device ens5 .

      In this exercise, you use the ip link utility to add, edit, and delete a link.

        Run the ip command without any options or arguments.

      Note: The various options available. Refer to the ip (8) man page for a description of all options.

      The show command is the default for the ip link object, so it is not required. The output identifies three network devices, two Ethernet devices ( ens3 and ens5 ). There is also one loopback device ( lo ). The output lists the same devices as the nmcli device status did in the previous exercise.

      • Use physical device ens5
      • Assign the name ens5.10
      • Use vlan for the device type
      • Assigh the VLAN ID ( id ) to 10
      ip link add link ens5 name ens5.10 type vlan id 10 
      ip link set ens5.10 mtu 1400 

      Run ip addr Object Commands

      The ip addr command to displays and manages IP addresses on network devices.

        Run the ip addr help command to show the available object commands.

      A partial list of available commands include add , change , replace , del , show , and save . Refer to the ip-address(8) man page for a complete list of ip addr commands.

      The show command is also the default for ip addr . It shows the same information as ip link but includes IP addresses.

      ip addr add 10.1.1.1/24 dev ens5 

      Источник

  • Оцените статью
    Adblock
    detector