Linux | Cloud | DevOps | Scripting

Breaking

Friday 22 August 2014

Network Setup

NETWORK SETUP
We can define network by three ways:


  1. Network Manager
  2. Network Configuration Files 
  3. Setup Command
NetworkManager:
Users do not interact with the NetworkManager system service directly. Instead, you can perform network configuration tasks via NetworkManager's Notification Area applet. The applet has multiple states that serve as visual indicators for the type of connection you are currently using. Hover the pointer over the applet icon for tooltip information on the current connection state. 



First check NetworkManager icon is showing on the right top corner of RedHat Desktop or not. If it is not showing then first install its package. 


# yum  install  NetworkManager*  -y

# service  NetworkManager  restart
# chkconfig  NetworkManager  on

If you do not see the NetworkManager applet in the GNOME panel, and assuming that the NetworkManager package is installed on your system, you can start the applet by running the following command as a normal user (not root):


# nm-applet


Now, right click on this icon and click on Edit Connections


Finally, clicking on Edit Connections opens the Network Connections window, from where you can perform most of your network configuration tasks. Note that this window can also be opened by running, as a normal user: # nm-connection-editor


Now click on Edit...


Here, in IPv4 tab there are some methods in Method tab:
  1. Autometic (DHCP)
  2. Autometic (DHCP) address only
  3. Manual
  4. Link-Local Only
  5. Shared to other computers
  6. Disbled
Configuring IPv4 Settings:
The IPv4 Settings tab allows you to configure the method by which you connect to the Internet and enter IP address, route, and DNS information as required. The IPv4 Settings tab is available when you create and modify one of the following connection types: wired, wireless, mobile broadband, VPN or DSL.

If you are using DHCP to obtain a dynamic IP address from a DHCP server, you can simply set Method to Automatic (DHCP).


SETTING THE METHOD:


Available IPv4 Methods by Connection Type

When you click the Method dropdown menu, depending on the type of connection you are configuring, you are able to select one of the following IPv4 connection methods. All of the methods are listed here according to which connection type or types they are associated with.

Method

Automatic (DHCP) — Choose this option if the network you are connecting to uses a DHCP server to assign IP addresses. You do not need to fill in the DHCP client ID field.

Automatic (DHCP) addresses only — Choose this option if the network you are connecting to uses a DHCP server to assign IP addresses but you want to assign DNS servers manually.


Link-Local Only — Choose this option if the network you are connecting to does not have a DHCP server and you do not want to assign IP addresses manually. Random addresses will be selected as per RFC 3927.


Shared to other computers — Choose this option if the interface you are configuring is for sharing an Internet or WAN connection.


Wired, Wireless and DSL Connection Methods

Manual — Choose this option if the network you are connecting to does not have a DHCP server and you want to assign IP addresses manually.

=> Now we are going to set network by manual  method




Addresses:

Address — The IP address of a network, sub-net or host.
Netmask — The netmask or prefix length of the IP address just entered.

Gateway — The IP address of the gateway leading to the network, sub-net or host.

Here, in Editing System eth1 popup window (your system might be using eth0 or eth2...), click on Add button to add a network manually,


Address — 192.168.0.10

Netmask — 255.255.255.0

Gateway — 192.168.0.254
Search Domain — example.com



# service NetworkManager restart

# chkconfig NetworkManager on

========================================================================

NETWORK CONFIGURATION FILES:

Before delving into the interface configuration files, let us first itemize the primary configuration files used in network configuration. Understanding the role these files play in setting up the network stack can be helpful when customizing a Red Hat Enterprise Linux system.

The primary network configuration files are as follows:

/etc/hosts
The main purpose of this file is to resolve host names that cannot be resolved any other way. It can also be used to resolve host names on small networks with no DNS server. Regardless of the type of network the computer is on, this file should contain a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain. 

/etc/resolv.conf
This file specifies the IP addresses of DNS servers and the search domain. Unless configured to do otherwise, the network initialization scripts populate this file. 

/etc/sysconfig/network
This file specifies routing and host information for all network interfaces. It is used to contain directives which are to have global effect and not to be interface specific.

/etc/sysconfig/network-scripts/ifcfg-eth0                 //here, eth0 is interface-name
For each network interface, there is a corresponding interface configuration script. Each of these files provide information specific to a particular network interface. 

Note: The /etc/sysconfig/networking/ directory is used by the now deprecated Network Administration Tool (system-config-network). Its contents should not be edited manually. Using only one method for network configuration is strongly encouraged, due to the risk of configuration deletion.


ETHERNET INTERFACES:
One of the most common interface files is /etc/sysconfig/network-scripts/ifcfg-eth0, which controls the first Ethernet network interface card or NIC in the system. In a system with multiple NICs, there are multiple ifcfg-ethX files (where X is a unique number corresponding to a specific interface). Because each device has its own configuration file, an administrator can control how each interface functions individually.


The following is a sample ifcfg-eth0 file for a system using a fixed (static) IP address:

DEVICE=eth0
BOOTPROTO=none
IPADDR=192.168.0.10
NETMASK=255.255.255.0
ONBOOT=yes

# service network restart
# chkconfig network on

The values required in an interface configuration file can change based on other values. For example, the ifcfg-eth0 file for an interface using dhcp looks different because IP information is provided by the dhcp server:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

# service network restart
# chkconfig network on

=====================================================================

Thanks for reading this article...

No comments:

Post a Comment

Pages