Red Hat Certified System Administration 8



Chapter 08: Configuring Networking


Sommaire

  • Interfaces
  • Resolving Names
  • Configuration Files
  • Ports and Services
  • Routing

Goal

To configure basic IPv4 networking on Red Hat Enterprise Linux systems.

Interfaces


Usual Commands

[root@lab ~]# ping IP address test connectivity with ICMP packets sending
[root@lab ~]# ping -cn IP
[root@lab ~]# ping -c5 host

Interfaces Naming

Le nom attribué aux interfaces réseaux par le système est constitué de 3 Parties

- La première partie indique le type ou la technologie
- La seconde partie indique le type d'adaptateur utilisé
- La troisième partie est un ID pour identifier de facon unique la carte

Network Technology

Technology Name Part (I)
Ethernet en
WLAN wl
WWAN WW
Virtual Interfaces virbr
Unknown eth

Network Adapter

The next character(s) represents the type of adapter with an
  • o for on-board,
  • s for hot plug slot,
  • p for PCI geographic location.

Interface ID

Not used by default but also available to administrators, an x is used to incorporate a MAC address Finally, a number N is used to represent an index , ID, or port.

NB
  • If the fixed name can not be determined , the traditional names such as ethN will be used.

Network interface naming can be overridden. If the administrator has installed and enabled the biosdevname package or set customized udev device naming rules, those settings will override the default naming scheme. Depending on support for biosdevname in the system BIOS, names such as em1, em2, etc . may be used for on board network cards (corresponding to their names on the chassis). PCl (e) cards are represented with pYpX (e.g., p4p1), where Y is the PCIs lot number and X is the number for the port on that specific card


Network Interfaces

Usual Commands

[root@lab ~]# ifconfig active interfaces list and settings
[root@lab ~]# ifconfig interface-name display an interface settings.
[root@lab ~]# ifconfig -a active & inactive interfaces list and their properties
[root@lab ~]# ifup interface activate an interface
[root@lab ~]# ifconfig interface-name up activate an interface
[root@lab ~]# ifconfig interface-name down deactivate an interface
[root@lab ~]# ifconfig interface-name IPaddress netmask mask attribute temporary an IP address to an interface

[root@lab ~]# ip addr Show all Devices and address information
[root@lab ~]# ip addr show interface Show Device and address information
[root@lab ~]# ip -s link show interface Show statistics about network performance

Static Addressing

Method 1 : nmstate (RHEL 9)

Install nmsate package:


Create YAML format of network cards profile file


Edit YAML file


Apply Profile



NetworkManager Command Line Tool (nmcli)

nmcli — command-line tool for controlling NetworkManager and reporting network status.

Display Settings

[root@lab ~]# nmcli con show Show Network Interfaces
[root@lab ~]# nmcli con show --active Show Network active Interfaces
[root@lab ~]# nmcli dev status Show Network Interfaces status
[root@lab ~]# nmcli dev show Interface-name Show Network Interface informations


Resolving Names



Resolving Names

Changing System Host name

[root@lab ~]# hostname Display System Host name
[root@lab ~]# hostnamectl set-hostname hostname Change System Host name stored in /etc/hostname
[root@lab ~]# hostnamectl status

The static host name is stored in /etc/hostname. Previous of Red Hat Enterprise Linux stored the host name as a variable in the /etc/sysconfig/network file.

Name Resolving

Red hat uses 2 ways to resolv addresses
  1. Configuration in /etc/hosts file
  2. Using DNS server

1 - Configuration in /etc/hosts File

IP Address hostname

Example
10.0.0.11 redhat.lab.tg

2 - Using DNS server

We must define DNS server address. We have 2 ways for that:

2.1 - in /etc/resolv.conf
nameserver DNS Server IP Address
nameserver 8.8.8.8
nameserver 4.4.4.4

NB: /etc/resolv.conf editing is temporary. It may change when network service restart

Au démarrage le service network configure /etc/resolv.conf avec les infos enregistrées /etc/sysconfig/network-scripts/interfacefile s’il y en a Sinon nous pouvons éditer /etc/resolv.conf mais la configuration se perd à l’arrêt du service network

2.2 - in /etc/sysconfig/network-scripts/interfacefile
DNS1=IP
DNS2=IP
DOMAIN=domain_name

DNS1=8.8.8.8
DNS2=4.4.4.4
DOMAIN=lab.bg

Files

/etc/nsswitch.conf DNS order file
/etc/resolv.conf DNS client file

We can define their priorities in /etc/nsswitch.conf
  • hosts: files dns /etc/hosts have priority
  • hosts: dns files DNS server have priority

Commands

[root@lab ~]# host Hostname Resolve name to IP
[root@lab ~]# host IP Resolve IP to name


Configuration Files



Configuration Files


/etc/services services and their ports
/etc/sysconfig/network-scripts/ Network Cards Configuration files Directory
/etc/sysconfig/network-scripts/ifcfg-interfacename [+]

/etc/nsswitch DNS order file
/etc/resolv.conf DNS client file [+]

NB: Il est possible d'éditer le fichier /etc/resolv.conf pour indiquer les adresses des serveurs DNS. Mais la configuration sera temporaire car c'est un fichier qui est généré au démarrage du networking

Pour configurer les adresses DNS de facon permanente il faur l'éditer dans le fichier de configuration de la carte réseau



Ports and Services



Ports and Services

netstat    |     ss

[root@lab ~]# netstat network statistics
[root@lab ~]# netstat -a all
[root@lab ~]# netstat -t specify TCP connections
[root@lab ~]# netstat -u specify UDP connections
[root@lab ~]# netstat -r show routage table
[root@lab ~]# netstat -c show in real time

[root@lab ~]# ss Display Sockets Statistics

Check opened port
  1. [root@redhat ~]# nc -Transport_protocol -z Host Port

  2. [root@redhat ~]# telnet Host Port

[root@redhat ~]# nc -u -z 10.0.0.7 53

[root@redhat ~]# nc -t -z 10.0.0.7 80



Routing



Routing

add a route
route add –net netIP/mask gw gatewayIP dev interface
route add default gw gatewayIP dev interface       for any network (0.0.0.0)

activate routage
edit /etc/sysctl.conf
net.ipv4.ip_forward = 0 change 0 to 1
tape command sysctl –p to activate settings and show settings

Show Routing Table

[root@lab ~]# route –n
[root@lab ~]# ip route
[root@lab ~]# netstat -r

Tracing Route
[root@lab ~]# traceroute host
[root@lab ~]# tracepath host



Eninam BAGNABANA     |         |     bagnadavid@outlook.fr     |