Thank you everybody for your very early and helpful replies, your replies not only fixed the issue alone, also inspired me a bit to do some wikipedia on networking basics.
The IP address that I assigned earlier without thinking that much, i.e.
RPi:
address 112.168.1.5
netmask 255.255.255.0
gateway 112.168.1.254
and at ubuntu side
address 112.168.1.254
netmask 255.255.255.0
gateway 112.168.1.5
That actually
worked after rebooting the Pi and I could establish an SSH connection in putty. Later I changed it to one of the private IP address as suggested by penguintutor.
Firstly I'm guessing you made up the 112.* IP addresses?
Not a good idea as they are registered to someone else in this case the address is managed by Korea Telecom. As long as you are not routing your network via Korea or want to connect to a site in Korea you are probably OK, but you can get strange problems.
Then I changed the IP addresses to something like:
Code: Select all
Rpi
ip 172.16.1.1
mask 255.255.255.0
gateway 172.16.1.2 //172.16.1.1 works too
ubuntu
ip 172.16.1.21
sub 255.255.255.0
gateway 172.16.1.1 //172.16.1.10 works too
That worked too. And now I understood why it is a good idea to use private IP addresses. I didn't used the 192.168.* IPs because they were already assigned to my tethered android device on usb0 for internet connection. But I don't understand why I can not connect to the internet through usb0 while the eth0 is connected. Can you point the issue out of it? Or is it unlikely a ubuntu side problem? I think there should not be any conflict between 192.168.* IP (usb0) and 172.16.* (eth0) IP addresses.
Whilst you have a gateway entry, if you are not using a router then you should not need a gateway address as the network expects that address to be a router
Exactly true. As I learned from wikipedia "a gateway is a node (a router) on a TCP/IP network that serves as an access point to another network". In this setup there is only a single network and so the gateway address is not necessary to let it connect to "another" network when the IP address doesn't match any other route in the routing table. So,
You have a gateway of 192.168.1.254.
Is that the IP address of your PC?
It is not necessarily needed.
Don't set the devices to be gateway for each other. All you need is something like this:
IP address of PC: 192.168.1.1
IP address of Rasperberry Pi: 192.168.1.2
Subnet mask on both: 255.255.255.0
Default gateway on both: 192.168.1.254
Yes. I did it before you've written

And I think as long as the PC and the RPi is connected directly, setting an IP address having same network part and different node is just good. And we need static IP on the both as there is no DHCP server.