Anda di halaman 1dari 6

10/22/13 Document 132044.

How to Configure Linux OS Ethernet TCP/IP Networking (Doc ID 132044.1)


Modified: 13-May-2013 Type: HOWTO

In this Document
Goal
Solution
1. Check If Kernel Recognized Network Card.
2. Configuring Network File
3. Create Network Interface File
4. Bring Up Network
5. Checking Network Device Up or Not
6. Shutting Down Inteface
7. Try Connecting
8. Routing Troubleshooting.
9. Verify Route and Default Gateway
10. Useful Network Commands

APPLIES TO:

Linux Kernel - Version: 1.0


Linux Itanium
Red Hat Enterprise Linux Advanced Server Itanium
UnitedLinux (32-bit)
Red Hat Enterprise Linux Advanced Server x86-64 (AMD Opteron Architecture)
Linux x86-64

GOAL

This note explains how to configure network interface using Ethernet and
TCP/IP protocol. The example here is based on LINUX OS but concepts are same
for most of the operating systems with minor variations.Also included are list
of usefull network commands.

SOLUTION

This document is intended for administrators with at least a basic understanding


of computer networking.

Following info is required (all this info can be obtained from the local System
Administrator):

The host name.


The domain name.
The computer's IP address.
The IP address of the network.
The netmask to use with the network.
The broadcast address to use on the network.
The IP address of the default gateway system to route to, if the network has a gateway.
The IP address of DNS (Domain Name Service) server.

Steps to configure network interface.

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=m4vae16ss_128&id=132044.1 1/6
10/22/13 Document 132044.1

In linux netcfg (GUI) can be used to configure but here will explain
configuration using network interface files.

1. Check If Kernel Recognized Network Card.

On a running system, to find if the kernel recognizing network interface card use the following

Command: % dmesg | grep -I eth

The output will be similar this:

NE*000 ethercard probe at 0x300: 00 40 05 48 2e 83


eth0: NE2000 found at 0x300, using IRQ 10.

2. Configuring Network File

Network file:/etc/sysconfig/network

NETWORKING =Yes
FORWARD_IPV4=YES < set it to YES only if linux server acts as gateway or router>
HOSTNAME= <host name>.<domain name>.com
DOMAINNAME = <domain name>
GATEWAY= <ip_address> For routing packet to and from your computer over a network.
GATEWAYDEV=<eth0/eth1> (This is important when there are multiple network interfaces. eth0
against
GATEWAYDEV shows only one interface. (eth0 is the RedHat Linux ethernet adapter default,
depending on Linux distribution) If there are multiple interfaces that specify the interface name
that will connect to default gateway.)

3. Create Network Interface File

Next step is to create network interface file:

/etc/sysconfig/network-scripts/ifcfg-interface

Naming convention: ifcfg-interface.


Ex; ifcfg-eth0 or ifcfg-eth1

/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
IPADDR=
NETMASK=
NETWORK=
BROADCAST=
ONBOOT=YES <set it to YES to be up during boot time)

Type in appropriate values for each item.

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=m4vae16ss_128&id=132044.1 2/6
10/22/13 Document 132044.1

4. Bring Up Network

After configuring these two files one should able to bring up the network.

%/etc/sysconfig/network-scripts/ifup eth0

5. Checking Network Device Up or Not

To check if device eth0 is up or not

%ifconfig eth0

Output should be similar to this:

eth0 Link encap:Ethernet HWaddr 00:B0:D0:26:F2:E5


inet addr:138.2.122.117 Bcast:138.2.122.255
Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
RX packets:2918510 errors:0 dropped:0 overruns:0 frame:0
TX packets:5476 errors:0 dropped:0 overruns:0 carrier:0
collisions:2 txqueuelen:100
Interrupt:11 Base address:0xdc00

6. Shutting Down Inteface

To shut down interface

% ifconfig eth0 down

7. Try Connecting

Once network is up and running try connecting to computer in your network.

% ping 192.168.0.2

The output should appear similar to this:

64 bytes from 192.168.0.2: icmp_seq=0 ttl=32 time=1.2 ms


64 bytes from 192.168.0.2: icmp_seq=1 ttl=32 time=1.0 ms
64 bytes from 192.168.0.2: icmp_seq=2 ttl=32 time=1.0 ms
64 bytes from 192.168.0.2: icmp_seq=3 ttl=32 time=1.0 ms
64 bytes from 192.168.0.2: icmp_seq=4 ttl=32 time=1.1 ms

If not able to ping a host using hostname then verify name server ip
address is correct or not in /etc/resolv.conf . There could be several
other reasons why ping may not work but this is one of the reasons and
one of the ways to get it working.
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=m4vae16ss_128&id=132044.1 3/6
10/22/13 Document 132044.1

%/etc/resolv.conf
contents of the file.
Two entries:
Search machine_name
Nameserver <ip_address>.

8. Routing Troubleshooting.

If ping is not working with IP address or hostname then there is routing


problem. This is commonly noticed if ifconfig is used to bring up network
interface. Using Ifup may not need this additional step.

Create a default route to your network and a default gateway manually.

% route add -net network address netmask device.

Ex:
To create a default route for an 307.171.20.40 network which has netmask
as 255.255.255.240 for eth0 interface

%route add -net 307.171.20.40 255.255.255.0 eth0

Default gateway

%route add default gw <gateway address device>

Ex: route add default gw <ip-address of gw> eth0

9. Verify Route and Default Gateway

%route -n or netstat -r

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface


ckclark-pc.us.o * 255.255.255.255 UH 00 0 eth0
138.2.156.0 * 255.255.252.0 U 00 0 eth0
127.0.0.0 * 255.0.0.0 U 00 0 lo
default 138.2.158.1 0.0.0.0 UG 00 0 eth0

Then do a ping this should work. Bingo your network is up and running and get
to go.

10. Useful Network Commands

List of useful network commands:


Note: Some of the commands requires root login.

A. To find if the Kernel recognizes network interface on a running system.


https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=m4vae16ss_128&id=132044.1 4/6
10/22/13 Document 132044.1

%dmesg | grep -I eth


Expected output
NE*000 ethercard probe at 0x300: 00 40 05 48 2e 83
eth0: NE2000 found at 0x300, using IRQ 10.

B. To bring up network
There are several methods but easiest way is to use following command:

%/etc/sysconfig/network-scripts/ifup <device/interface name>


ex:/etc/sysconfig/network-scripts/ifup eth0

C. To shutdown network

%Ifconfig eth0 down

D. To check if given IP address is recognized by Domain Names server

% nslookup <IP address>/<machine name>

Ex output:
Server: dns1.us.oracle.com
Address: 144.25.88.144

Name: aoltst1.us.oracle.com
Address: 138.2.122.117

This should return output if the DNS recognizes IP address or node name.
If not then DNS needs to be configured. To run nslookup interactively just
type in

% nslookup <enter>

To get help type

% nslookup ? or help

E. To display status of the network connections both to and from local system

% netstat -a -r -c -I

-a displays all the network connection on the local system.


-r To display routing table
-c To display network connection status on a continuous basis
-I To display information on all network interfaces, use the -I option

The above command will display all the information about network.

G. To check machine name

%hostname

H. To check if a remote computer is reachable via the TCP/IP protocol.

%ping

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=m4vae16ss_128&id=132044.1 5/6
10/22/13 Document 132044.1

I. To check max packet size that is transmittable on your network

%ping -c 1 -s <100016> hostname


-c Number of times a packet needs to be sent
-s Packet size
-100016 is an arbitrarily number.

The above command with packet size of 100016 errored out with following
message

Error: packet size 100000 is too large. Maximum is 65507


Obviously 65507 is the max packet size.
To interrupt PING type <cntrl C>

J. To debug network

%tcpdump host <hostname> and <hostname>

The above command will make tcpdump listen for packets between two computers.
This will display the FTP-realted packets that are originating and arriving
to your network.

K. To verify network route and default gateway are properly set up in routing
table

%route -n

L. To find network routing problems

%traceroute host or Ipaddress

M. To get additional information on Linux visit http://www.linux.org.

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=m4vae16ss_128&id=132044.1 6/6

Anda mungkin juga menyukai