How To Configure Networks In Red Hat Enterprise Linux

Introduction of IP Address

An IP address is a 32 bit number assigned to each host on a network. It is a combination of  Network ID and Host ID. It is launched by IANA- Internet Assigned Number Authority.  IANA is a department of  ICANN (Internet Corporation for Assigned Names and Numbers) is the private (non-government) non-profit corporation with responsibility for IP address space allocation. An IP address is a software (logical) address, not a hardware (physical) address. IP addressing was designed to allow host on one network to communicate with the host on a different network.

An IP address is usually represented in dot-decimal notation, consisting of four-decimal numbers separated by periods (e.g. 192.168.0.1). the first of the address usually represents a network device (192.168.0.0), while the last part of the address identifies the host device (e.g. 192.168.0.1).

IPv4 IPv6
It has 32 bits It has 128 bits
Contain only 4 block It contain 8 block
8 bits in one block 16 bits in one block
e.g. 192.168.0.1 ABCD:0000:0000:0000:23B2:00FF:B231:12AC
Decimal Hexadecimal
Dotted (.) Colane (:)

Classes of Addressing: The developers of the internet planned to create classes of networks as per there network size. The classes of network are:

Classes Network Range Use Leading Bits
A 0-127 (1-126 in use) Large network 1 (0)
B 128-191 Medium network 2 (10)
C 192-223 Small network 3 (110)
D 224-239 Multicast address 4 (1110)
E 240-255 R & D 4 (1111)
IP Address Class First bit value Class A 0 Class B 10 Class C 110
Range 1 to 126 128 to 191 192 to 223
Network ID bits 8 16 24
Host ID bits 24 16 8
Total no of network 126 16,384 20,97,152
Total no of host 1,67,77,214 65,534 254
Default Subnet Mask 255.0.0.0 255.255.0.0 255.255.255.0

There are two types of IP address, one is public and other is private.

Public IP address: A public IP address is assigned to every computer that connects to the Internet where each IP is unique. Hence there cannot exist two computers with the same public IP address all over the Internet. The public IP address is assigned to the computer by the Internet Service Provider (ISP) as soon as the computer is connected to the Internet Gateway.

Private IP address: The private IP addresses can be used on the private network of any organization in the world and are not globally unique.There addresses can be used on a private network, but they’re not routable through the Internet. It is designed for the purpose of creating a measure of well-needed security, but it also conveniently saves valuable IP address space.

Network interface Names:

Ethernet interface begin with en, WLAN interface bein with wl, and WWAN interfaces begin with ww. The next character represents the type of adapter with an o for on-board, s for hot-plugslot, and p for PCi. a number N is used to represent an index, ID, or port. If the fixed name cannot be determined, the traditional  names such as ethN will be used.

Example: en01, the first embedded network interface and enp2s0, a PI card network interface.

Network Display and Troubleshooting Commands:

ifconfig(interface Configurator) command is using to initialize and interface, assign IP Address to interface and enable or disable interface on demand. With this command, you can view IP Address and MAC address assign to interface. PING (Packet INternet Groper) command is the best way to test connectivity between two nodes. Traceroute is a network troubleshooting utility which shows number of hops taken to reach destination also determine packets travelling path. Netstat (Network Statistic) command display connection info, routing table information etc. Route command also shows and manipulate ip routing table. Host command to find name to IP or IP to name in IPv4

or IPv6 and also query DNS records. Hostname is to identify in a network. Execute hostname command to see the hostname of your box. The ss command is used to display Socket Statistics. It is similar to the netstat command.

Display the ip address
[root@asim ~]# ifconfig
Display IP address for eth0 interface
[root@asim ~]# ifconfig ens33
Display IP address and netmask to all interfaces
[root@asim ~]#ip addr
Details information about interface
[root@asim ~]#ip addr show
Details information about eth0 interface
[root@asim ~]#ip addr show ens33
Display device attributes
[root@asim ~]#ip link show
Display statistics for all interface
[root@asim ~]#ip –s link show
Display statistics for eth0 interface
[root@asim ~]#ip –s link show ens33
Display the routing information
[root@asim ~]#ip route show
Display the routing information
[root@asim ~]#netstat -nr
Display the routing information
[root@asim ~]#netstat -r
Display the routing information
[root@asim ~]#route
Test connectivity
[root@asim ~]#ping
Test connectivity number of replay
[root@asim ~]#ping –c3
Gives routing info
[root@asim ~]#traceroute
Alternative to traceroute
[root@asim ~]#tracepath
Display listening TCP socket
[root@asim ~]#ss -lt

Network Manager:

This is collection of GUI (Graphical User Interface), TUI (Text User Interface), and CLI (Command Line Interface) utilities that are used to configure your network settings. All these utilities interact with the NetworkManager service: NetworkManager is a daemon that monitors and manages network settings.

Configure Network with ifconfig:

ifconfig in short ‘Interface Configuration’ utility for in Linux operating system to configure, manage and query network interface parameters via command line interface or in a system configuration scripts. The ‘ifconfig’ command is used for displaying current network configuration information, setting up an ip address, or netmsk to a network interface, setting up hardware address and enable or disable network interfaces.

Display all the active interface Details
[root@asim ~]#ifconfig
Display all the active or inactive network details
[root@asim ~]#ifconfig -a
Display details of specific network interface
[root@asim ~]#ifconfig ens33
Activates a network interface
[root@asim ~]#ifconfig ens33 up
Deactivates the specified network Interface
[root@asim ~]#ifconfig ens33 down
Assign and IP address to a specific interface
[root@asim ~]#ifconfig ens33 192.168.1.1
Assign a Netmask to network interface
[root@asim ~]#ifconfig eth0 netmask 255.255.255.254
Assign a IP and Netmask to network interface
[root@asim ~]#ifconfig eth0 1.1.1.1 nestmask 255.0.0.0
Change MTU for a network interface
[root@asim ~]#ifconfig ens33 mtu 1000
Chang the MAC address of network interface
[root@asim ~]#ifconfig eth0 hw ether aa:bb:cc:dd:ee:ff

Configure Network With NMCLI:

NMCLI stands for (Network Manager Command Line Interface). NMCLI is a command-line tool for controlling NetworkManager and getting its status. nmcli is used to create, display, edit, delete, activate, and deactivate network connection, as well as control and display network device status. nmcli add syntax: #nmcli connection add type Ethernet con-name NAME_OF_CONNECTION ifname interface-name ip4 IP_ADDRESS gw4 GW_ADDRESS

Replacing the NAME_OF_CONNECTION with the name you wish to apply to new connection, the IP_ADDRESS with the IP address you wish to use and the GW_ADDRESS with the gateway address you use.

Display detailed info about device
[root@asim ~]#nmcli device show
Display list of network device
[root@asim ~]#nmcli device
Display list of network device state
[root@asim ~]#nmcli device status
Disconnect the interface
[root@asim ~]#nmcli dev dis ens33
Connect the interface
[root@asim ~]#nmcli dev con ens33
Adding an Ethernet connection with static IP
[root@asim ~]#nmcli con add type ethernet con-name eth1 ifname ens33 ip4 192.168.220.2 gw 192.168.220.1
Set the DNS servers for New connection
[root@asim ~]#nmcli con mod eth1 ipv4.dns 8.8.8.8 8.8.4.4
Add additional DNS value
[root@asim ~]#nmcli con mod eth1 +ipv.dns 4.4.4.4
Add additional IP address
[root@asim ~]#nmcli con mod eth1 +ipv4.addresses 192.168.220.10/24
Up the new Ethernet connection ens33
[root@asim ~]#nmcli con up eth1
Display detailed information  of New connection
[root@asim ~]#nmcli –p con show eth1
Adding connection using DHCP, con-name
[root@asim ~]#nmcli con add type ethernet eth1_dhcp ifname eth1_dhcp ens33
Activate the connection
[root@asim ~]#nmcli con up eth1
Deactivate the connection
[root@asim ~]#nmcli con down eth1
Delete the connection
[root@asim ~]#nmcli con dell eth1
Display available connection
[root@asim ~]#nmcli con show
Display details of a specific Connection
[root@asim ~]#nmcli con show ens33
Display only active connection
[root@asim ~]#nmcli con show -a
Display help of NMCLI command
[root@asim ~]#nmcli help
Graphical tool for NMCLI
[root@asim ~]#nm-connection-editor
permanently assign hostname using hostnamectl command
[root@asim ~]#hostname set-hostname cms.panvel.com
Display hostname status
[root@asim ~]#hostname status
Display hostname
[root@asim ~]#cat /etc/hostname
Change hostname permanently
[root@asim ~]#vim /etc/hostname
Display hostname details
[root@asim ~]#cat /etc/hosts
Maps hostnames to IP addresses locally
[root@asim ~]#vim /etc/hosts

Configuring Name Resolution:

The /etc/resolv.conf file contains directives with the IP addresses of nameservers available to a host. The /etc/hosts file keeps a local name database. This file helps in local name resolution if yourlocal DNS server is not functioning. You can manually populate entries in this file.

Change DNS server
[root@asim ~]#cat /etc/resolv.conf
Change DNS server entries in interface configuration file
[root@asim ~]#vim /etc/syscongif/network-scripts/ifcfg-ens33 DNS1=8.8.8.8 DNS2=4.4.4.4
Configure DNS server entries using nmcli command
[root@asim ~]#nmcli con mod ens33 ipv4.dns 8.8.8.8
Map hostname to IP and IP to hostname
[root@asim ~]#vim /etc/hosts
Lookup IP address of hostname
[root@asim ~]#host www.eiheducation.com

Leave a Reply

Your email address will not be published. Required fields are marked *