Create New Post

Configuring network interfaces

Configuring network interfaces in CentOS involves setting up IP addresses, subnet masks, gateways, DNS servers, and other network settings to establish network connectivity. Here's how you can configure network interfaces in CentOS:

1. Using NetworkManager:

  • NetworkManager is the default network configuration tool in CentOS, providing a graphical and command-line interface for managing network connections.

Graphical Interface (GNOME Desktop):

  • Click on the network icon in the system tray and select "Wired Settings" or "Wi-Fi Settings" to access network settings.
  • Configure IP addresses, DNS servers, and other network settings through the graphical interface.

Command-Line Interface (nmcli):

  • Use the nmcli command-line tool to manage network connections.
  • List available network connections:
    nmcli connection show 
  • Edit a network connection:
    nmcli connection edit connection_name 
  • Set IP address, gateway, and DNS server:
    nmcli connection modify connection_name ipv4.addresses IP_Address/Subnet_Mask
    nmcli connection modify connection_name ipv4.gateway Gateway_IP
    nmcli connection modify connection_name ipv4.dns DNS_Server_IP
    
  • Activate the connection:
    nmcli connection up connection_name 

2. Using Network Scripts:

  • Alternatively, you can configure network interfaces manually by editing network configuration files in /etc/sysconfig/network-scripts/.

Edit Configuration Files:

  • Navigate to /etc/sysconfig/network-scripts/ directory.
  • Edit the appropriate network configuration file using a text editor (e.g., ifcfg-eth0 for Ethernet interfaces).
  • Set the following parameters in the configuration file:
    DEVICE=eth0
    BOOTPROTO=static
    IPADDR=192.168.1.100
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    DNS1=8.8.8.8
    DNS2=8.8.4.4
    ONBOOT=yes
     

Restart Network Service:

  • Restart the network service to apply changes:
    sudo systemctl restart network 

3. Using NetworkManager Text User Interface (nmtui):

  • If you prefer a text-based interface, you can use nmtui to configure network interfaces interactively.
  • Open the text-based interface:
    sudo nmtui 
  • Use the arrow keys to navigate and configure network settings.

4. Verifying Network Configuration:

  • Use commands like ip addr show or ifconfig to verify the configured network settings.
  • Test network connectivity using commands like ping or curl.

Comments

Leave a Reply

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

63039