Raspberry: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 62: Line 62:
sudo fing -n 192.168.1.1/24
sudo fing -n 192.168.1.1/24
</pre>
</pre>
 
where /24 means 'network prefix' size 24 bits.
* [http://angryip.org Angry ip scanner] cross platform. open source. Basic knowledge on internet protocol.
* [http://angryip.org Angry ip scanner] cross platform. open source. Basic knowledge on internet protocol.



Revision as of 14:07, 11 March 2013

Raspberry Pi

Miscellaneous

Get internet from sharing the internet from another machine

  • https://wiki.archlinux.org/index.php/Internet_Share
  • static iP. Set up host eth0 IP and then set up RPi IP:
    • In Windows, allow Internet sharing. An IP of 192.168.0.2 will be automatically assigned to the Laptop's network card. Make static IP of 192.168.0.2 in Rasp Pi. Enter subnet mask and gateway (192.168.0.1). Also make an entry in /etc/resolv.conf with nameserver=192.168.0.1. Reboot and Rasp Pi will get Net all right.
    • In Linux, An IP of 10.42.0.37 will be assigned to eth0 card. Make static IP of 10.42.0.37 in Rasp Pi. Enter subset mask and gateway (10.42.0.1). Also make an entry in /etc/resolv.conf with nameserver=10.42.0.1. Reboot and Rasp Pi will get Net all right.
    • Other thoughts:
sudo nano /etc/network/interfaces

iface eth0 inet static
address 192.168.100.1
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
gateway 192.168.100.254

The gateway is important and in most cases will always point to your firewalls, switch or routers IP address.

In my current setting, the host machine's eth0 has IP 10.42.0.1 (inet addr). The RPi has IP 10.42.0.37 and gateway 10.42.0.1.

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0
10.42.0.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0

And /etc/resolv.conf may be worth to be changed too. /etc/hostname and /etc/hosts are unnecessary.

An example of /etc/resolv.conf (set up linux DNS) shown from my RPi is

nameserver 10.42.0.1

But maybe another choice is nameserver 8.8.8.8.

Some tools for discovering the IPs in a network include Fing (iOS/Android) or Scapy (python).

IP scan tools

  • fing (ios, android, linux, windows). Command line usage
sudo fing -n 192.168.1.1/24

where /24 means 'network prefix' size 24 bits.

  • Angry ip scanner cross platform. open source. Basic knowledge on internet protocol.

GPIO experiments

Blink a single LED

I follow the instruction in https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/ to install gpio program/library in raspberry pi. Here is the result

  • without PI cobbler: http://www.youtube.com/watch?v=xWJZRK4W13Q
  • with PI cobbler: see the picture below. The soldering part is not easy for a beginner. Be sure to follow some instruction on youtube videos to begin with. Note that the white stripe is on the edge closest to the SD card.

SingleLED.jpg

16x2 LCD

http://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi