Saturday, July 20, 2013

Network Setting in RHEL6

In this blog we will look, how to configure network setup to allow system to communicate to each other.
Networking is an important factor because without it, you would not be able to communicate with your network, or share files with your users.
When you’re working with network interfaces, there are two files you need to know:
/etc/sysconfig/network :This file contains gateway and hostname information.
/etc/sysconfig/network-scripts :This directory contains all the interface config files for your system.

Let’s start by looking at the hostname and networking information:
# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=RHEL01
The first two lines tell the system whether or not to enable networking for IPv4 and IPv6. By default, they are both enabled. The third option defines the system hostname. Each network interface has its own config file in this directory that follows the format ifcfg-ethX, where X is the number of the network card. For example,
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=08:00:27:30:74:AA
ONBOOT=yes
DHCP_HOSTNAME=RHEL01
TYPE=Ethernet

DEVICE=              interface you are working with.
BOOTPROTO=    protocol in use in my case it is DHCP.
HWADDR=          MAC address of device.
ONBOOT=           interface is enable during booting.
TYPE=                  you are using Ethernet technology.

You can launch system-config-network-tui utillity to change ip address if required.
Or you can also use following command to assign static ip address.
# ifconfig eth0 172.168.1.1 netmask 255.255.255.0

To bring the interface down, use ifdown:
# ifdown eth0

To bring the interface up use ifup:
# ifup eth0

To view the current IP address of the eth0 interface, use the following command:
# ifconfig eth0

When you made any changes with your adapter do'nt forget to restart the network service:
# service network restart

Additional network commands
ping command Tests the connectivity between two hosts
example #ping -c 2 192.168.1.1

traceroute command Looks for step by step path from host to host
example #traceroute 192.168.1.1

netstat command Shows information about connections (open, closed, and listening)
exmaple #netstat -tuape |grep sshd
tcp 0 0 *:ssh *:* LISTEN root 8627 2674/sshd
If nothing is returned, there is chance that the service isn't running or listening.

route command Shows routing information
#route

When you really need to see the details of what is going you can use a packet capture utility to view data being sent across the interfaces on your machine. you can use the tcpdump utility.
# tcpdump –i eth0 –w capturefile
-i means interface
-w means write in to file (capture file is the name of file)

To review the information you've captured, call the tcpdump program again:
# tcpdump –r capturefile | less
-r means read from file

No comments:

Post a Comment