vishalkumar uppin wrote:1.Mainly pi is not getting connected to the internet using the ethernet cable.
2.pi is not getting connected to any of the devices through ethernet lets say it could be router or else it could be some other c from where I want to do ssh.
3.i want to do ssh.so if i connect it to my pc using ethernet cable its taking its default ip i.e 169.254.xxx.xxx instead of my pcs ip.
4.os
Raspbeery pi- Raspbian jessie.
PC - windows 7
This is a very difficult description of your configuration. Networking is a difficult subject because there can be so many variables that can make solving a problem difficult. To be really successful it is necessary to have a very broad knowledge of all the components and software involved. I have already explained why the interface(s) have been assigned an IP-address in the 169.254.0.0/16 subnet, this means that a DHCP server was not found.
I still do not have a clear understanding on how you are connecting the Pi to the "internet", before I go into this I have to explain something. DHCP (Dynamic Host Configuration Protocol) is used to deliver a network configuration to a client (host). The basic configuration parameters are IP-address, subnet mask, router address, and (optionally) dns server address. If the host does not receive a reply from a DHCP server the host will randomly use an address in the subnet 169.254.0.0/16. (
https://tools.ietf.org/html/rfc3927) with subnet mask 255.255.0.0, default gateway and DNS server will be left blank. (per definition the subnet can not be routed!)
In most home networks there will be a DHCP server in the internet router or WiFi access point serving the local subnet only because DHCP traffic will not be routed. Normally a client connected to the internet router with an ethernet cable, or using WiFi to the access point, will receive an IP-address from the DHCP server. If the DHCP server can not be reached you will see 169.254.0.0/16 addresses.
Note: You must be aware that is possible to connect a computer directly to the internet modem, in this case the DHCP server will be with the internet service provider. There are historic reasons why some of the features exist.
When you use an ethernet cable to connect the Pi to a computer there will be a problem with DHCP because there is no DHCP server on the cable. For this reason each interface will assign an address in the 169.254.0.0/16 network.
There are two options to make this work, each has advantages and disadvantages. I will start with the one that has most disadvantages.
The first option is to bridge network interfaces on your computer. You can use your WiFi interface to connect to your access point and the cable to to connect to your Pi. In this case the local DHCP server in the router/access point will be used by the Pi and the computer. You must be aware that this option does not work if the computer is connected to the internet modem because the ISP DHCP server will not support this.
The second option is to configure ICS on the interface connected to the internet to provide access on the another private interface. In this case a mini DHCP server will be installed on the computer which will be used to provide clients on the private interface with a private IP-address (192.168.137.x). At the same time the computer will be configured to function as a gateway and DNS forwarder on the private ethernet interface address. For a PC connected to an internet modem this is the option to share internet to other clients.
The first option (bridging) has the disadvantage that you must always have a connection to a network for the PI to be able to request configuration parameters from the DHCP server. The second option will always work, even when you do not have a connection to the network.
However, you can communicate from the computer to the PI using 169.254.0.0/16 addresses with the use of avahi/bonjour, but for internet from the Pi you need a proper IP-address.