Sie sind auf Seite 1von 22

Meltwater's Raspberry Pi Hardware

Raspberry Pi Educational Hardware Kits


stay updated via rss

Guide ToDirect Network Connection


159

Raspberry Pi Remote Connections Without A


Network!
No keyboard or screen available for your Raspberry Pi, but you have a laptop?
There are often times when a HDMI monitor is not available to use with your Raspberry Pi. In those
circumstances it can be very useful to remote connect using a nearby network and a laptop (see
the Guide toRemote Connections (http://pihw.wordpress.com/guides/guide-to-remote-connections/)).
However, sometimes there isnt a network available either!
So how can we make use of a laptop screen and keyboard when there is no network?
As discussed previously (in the Guide toRemote Connections
(http://pihw.wordpress.com/guides/guide-to-remote-connections/)), there is the option of using a
(console) TTL-serial cable, however this only provides rather slow access. The serial connection wont
support X11 (which as we have seen, allows us to run graphical programs too), and you wont be able
use VNC or shared folders if you have them setup.
The answer is a simple network cable!
(http://pihw.files.wordpress.com/2013/04/directconnect1.png)
Connect and use your Raspberry Pi with just a Network Cable, a standard Imaged SD Card and
Power!
It is advisable to set this up before you need it so you can be sure that it is configured and working
correctly. As long as you have an SD-Card reader available, you can switch between the configurations
using a laptop (or directly on the Raspberry Pi if you have a screen/keyboard at the time).

Remember if you need the wired network for your computer (i.e. to get internet) then you shall have to
make a choice about which one you wish to use (or get an extra network port by adding a USB
network dongle). If you use wireless connections, then you can still have both!
Any standard network cable should be suitable (needs to have a male RJ45 connector on each end),
most cables available will be fine for our needs.
Note: You can use a normal network cable since the Raspberry Pi LAN chip is smart enough to reconfigure
itself for direct network connections (in the past older computers would have needed a special cross-over
cable).
Ive also created a cut-down version of the instructions for more advanced users who wont need all
the details:
In A Nut ShellDirect Network Connection (http://pihw.wordpress.com/guides/direct-networkconnection/in-a-nut-shell-direct-network-connection/)

How to use a direct network cable


What are we trying to achieve?
A good way to remotely control a Raspberry Pi is to connect it to a network and use one of the methods
discussed in the Guide toRemote Connections (http://pihw.wordpress.com/guides/guide-to-remoteconnections/). This will provide access to the terminal, by usig SSH, even the ability to view the desktop
using VNC, or the ability to run graphical programs as if they were running directly on the laptop itself
(see below for X11 Forwarding). We just need to make the network link work directly without requring
a full network setup (with Router etc).

Making a network connection work


Normally, if you take a Raspberry Pi and directly connect it to a network, it will attempt to
automatically find an IP address (see bottom of the page for information about IP Addresses and what
they are) by requesting one from your Router or other device running a DHCP server (a protocol which
automatically deals out addresses to computers as they attach to a network).
However, if you connect the Raspberry Pi directly to another computer, not a lot will happen. The
Raspberry Pi wont get an IP Address since there isnt a DHCP server to talk to (it cant talk to anything
other than the laptop).

Other computers will often give themselves a default address (in the address range 169.254.0.0

Other computers will often give themselves a default address (in the address range 169.254.0.0
169.254.255.255) but the Raspberry Pi doesnt do this (yet). Besides even if the Raspberry Pi did, we
would still need to know what address it had picked to be able to connect to it!
To get around this, we have to give the Raspberry Pi a fixed IP address (i.e. we tell it what its IP
Address should be so it doesnt have to wait for one).
There is just one complication to this, and that is if your laptop is configured to a fixed IP too. At first
this may not seem like a problem, since if both IPs are fixed then we will know the address of both
computers every time.
However for them to be able to talk to each other directly, they need to have similar addresses (at
minimum the first number should match, but we shall match at least the first 2 in this case to work with
default network settings). For more information on this, see the section at the bottom of the page about
SUBNETs.

Step 1 Find the Laptops Network Settings


Before we power up our Raspberry Pi, we can have a look at the network settings of the computer we
are planning on connecting to and determine if the address is automatically allocated or fixed.

Windows Instructions:
1. From the Start Menu, run the Control Panel.
(Windows 7/Vista) Open Network and Sharing Center and click on Change adapter settings on
the left side.
(Windows XP) Open Network Connections
2. Find the item which relates to your Wired network adaptor (by default this is usually called Local
Area Connection).
(http://pihw.files.wordpress.com/2013/04/networkadaptors.png)
Locate the Wired Network Adaptor Local Area Connection
3. Right-click on it and open Properties.
(http://pihw.files.wordpress.com/2013/04/networkproperties.png)
Network Properties Window, find the TCP/IP Entry
4. Select the item which is called Internet Protocol (TCP/IP) or Internet Protocol Version 4
(TCP/IPv4) if there are two (the other is Version 6), and open the Properties.

(http://pihw.files.wordpress.com/2013/04/networkpropertiesauto.png)
Wired Network Adaptor is configured as Automatic
Hopefully, the IP Address will be set to Obtain an IP address automatically. If not dont worry, just
take a note of the IP address and Subnet Mask set here (you may find the rest of the information useful
to keep, but we wont need it this time). If you know what you are doing, you can change this setting
to automatic, or you can leave it alone (we shouldnt need to adjust it as long as we know the IP
Address).

Mac and Linux:


You will need to locate the settings for your wired adaptor and check to see if the IP Address is
configured automatically, or fixed to a specific value.
To get to network settings on Mac OS X:
1) Load System Preferences.
2) Click Networks.
(http://pihw.files.wordpress.com/2013/04/mac-lan-auto.png)
(MAC) Wired Network Adaptor is configured as Automatic

Step 2 Setting the Raspberry Pis IP address


Option 1: Quick Setup / Setting up when you dont have a monitor
This quick method skips all of the testing which can be performed if we have a Raspberry Pi running
with a monitor and keyboard attached. If you run into problems, then follow the steps in Option 2, to
test the network settings.
1. Ensure the Raspberry Pi is powered off, and remove the SD-Card.
2. Insert the SD-Card into a card reader and plug it into your laptop.
3. Find the drive and you should find several files on the Card (note it a lot smaller than youd expect
since it is only the boot section of the Card (the rest is hidden)).
4. Make a copy of cmdline.txt and rename it cmdline.normal
5. Edit cmdline.txt and add the IP address at the end (be sure you dont add any extra lines).

For network settings where the IP address is obtained automatically, use an address in the range
169.254.X.X (169.254.0.0 169.254.255.255):

ip=169.254.0.2
For network settings where the IP address is fixed, use an address which matches the laptop/computers
address except the last one.

ip=192.168.0.2
Ensure you take note of this IP address (you will need it every time you want to directly connect to
the Raspberry Pi).
6. Make new copy of cmdline.txt and rename it cmdline.direct
7. To swap between configurations, just replace cmdline.txt with either cmdline.normal
or cmdline.direct (or use the commands in Option 2 to do it directly on the Raspberry Pi the change
will take effect next time you power up)
8. Return the card to the Raspberry Pi. Attach the network cable attached to both the computer and
Raspberry Pi and power up.
NOTE THE FOLLOWING:
1. You will need to wait for your computer to finish detecting the network settings (you may see a small
networking icon flashing in your system tray while it does, or open up the network settings to see when
it has finished and has an IP address) it can take around 1/2 minute. Your computer may report the
connection as limited or no connection when connected to the Raspberry Pi in this way, this is
normal as indicates it is a direct computer to computer connection rather than a standard network.
2. If you forget or decide not to plug in the network cable, the Raspberry Pi will wait 2 minutes (or
until you connect the cable) before completing its start-up (so if you only have a keyboard and
monitor attached, you need to wait!).
3. If you are using multiple wired network adaptors (i.e. Using an extra USB-LAN dongle) on your
computer you may find you have to unplug the other network cable and reattach afterwards (my
Windows XP machine needed this before it would connect through the direct link).

Option 2: Set-up using a monitor and keyboard (i.e. before you really need
it):
You will now see that having a keyboard and monitor available at this stage is helpful for when we set

You will now see that having a keyboard and monitor available at this stage is helpful for when we set
this up, as we can test each step.
1. Boot up the Raspberry Pi and plug in the network cable to both machines.
2. When the Raspberry Pi has booted ensure you log in and open the terminal if not already open.
Type the following:

hostname -I
You will probably find that nothing is shown, as this is trying to show you the current IP address
(which is not allocated yet). If it does show something, then you may have already have a fixed IP
address (if you do take note of it in case you need to put it back later).
3. Now set the new address as follows:
For network settings where the IP address is obtained automatically, use an address in the range
169.254.X.X (169.254.0.0 169.254.255.255):

sudo ifconfig eth0 169.254.0.2


For network settings where the IP address is fixed, use an address which matches the laptop/computers
address except the last number.

sudo ifconfig eth0 192.168.0.2


4. We can check this has worked by rechecking the IP address:

hostname -I
You will see we now have the IP address set.
We should now be able to ping the laptop.
5. Find the laptop address (if it wasnt a fixed address) by returning to the list of Network Adaptors in
windows and double clicking on the icon to see its Status (dont worry about the warning of limited
or no connection).
Then select the Support tab and then Details. You should see the laptops IP address.

ping 169.254.0.1
We should get lots of responses (the laptop is responding the Raspberry Pi through the network cable)!
Ctrl+C to stop that. (If you didnt then double check your connections and the IP addresses you are
using).
As mentioned before, the new IP address will be lost when we reboot, so we need to ensure it is set every
time we boot (or at least every time we want it to be when we boot).
To do that we can edit the cmdline.txt file which is located on the boot partition of the SD Card.
6. Make a copy of the file, with the following command:

sudo cp /boot/cmdline.txt /boot/cmdline.normal


7. Next edit the original file using nano:

sudo nano /boot/cmdline.txt


At the end of the long line, add the following (you will need to add a space between the last item and
ip:

ip=169.254.0.2
Ctrl+x and y to save and exit.
8. Make a copy of this file too:

sudo cp /boot/cmdline.txt /boot/cmdline.direct


9. You can now reboot the Raspberry Pi (sudo reboot), and next time the IP address will be
automatically set.
10. To change between configurations, simply use the following commands (just remember to
edit /boot/cmdline.direct if you need to change the IP address in future).

sudo cp /boot/cmdline.normal /boot/cmdline.txt


sudo cp /boot/cmdline.direct /boot/cmdline.txt

Summary
Now you should be able to do most of the things you would normally do when connected to a network.
It is even possible to use this direct network link to share your laptop/computers internet connection (if
it is connected via Wifi for example), although Ive not needed to do this yet.
One VERY useful thing to do is to set up Putty and Xming to allow you to control the terminal and
graphical programs directly from your laptop/computer.
(http://pihw.files.wordpress.com/2013/03/scratch-x11.png)
Scratch running nicely inside a window using X-11!
See the main Guide toRemote Connections (http://pihw.wordpress.com/guides/guide-to-remoteconnections/) for links for how to set-up VNC and shared folders, and X-11 on other computers.

Step 3 (recommended) Install Putty and Xming Server (for


SSH and X11)
I am assuming you are using the latest version of Raspbian (http://www.raspberrypi.org/downloads)
which has SSH and X11 Forwarding enabled by default (if not see the bottom of this post to enable
them if things dont work).

1. Install and run a X-Windows server on your computer


Download and run http://sourceforge.net/projects/xming/ (http://sourceforge.net/projects/xming/) from
the Xming (http://people.arsc.edu/~murakami/xming/) site.
Follow the installation, including installing Putty if you dont have it already. You can also
download Putty separately from http://www.putty.org/ (http://www.putty.org/)

2. Ensure your SSH program (Putty) has X-11 enabled.


In the PuTTY configuration, find Connection, SSH, X11 and tick the check-box for X11

In the PuTTY configuration, find Connection, SSH, X11 and tick the check-box for X11
forwarding. If you leave the X display location blank, it will assume the default Server 0:0 (you can
confirm the server number by hovering your mouse over the Xming icon in the system tray when it is
running). You can save your set-up within Putty so you will wont have to do this each time.
(http://pihw.files.wordpress.com/2013/03/puttycongif-x11.png)
Putty Configuration for X11 Forwarding

3. Enter the Raspberry Pis IP Address


(http://pihw.files.wordpress.com/2013/03/puttyconfig.png)
Putty Configuration for given IP
Enter the IP Address of the Raspberry Pi in the Session settings above (you may also find that you can
use the Raspberry Pis hostname here instead (default: raspberrypi)).
Save the setting using a suitable name (RaspberryPiDirect) and press open to connect to your
Raspberry Pi. You will likely get a warning pop-up stating you havent connected to the computer
before (allows you to check you have everything right before continuing).
All being well, you should be greeted with a prompt for your username and password (remember the
defaults are pi and raspberry).

4. Using X11 and Xming


Ensure you have Xming running, by starting the Xming program from your computers start menu and
then in the terminal window, type a program which normally runs within the Raspberry Pi desktop
(such as leafpad or scratch). Wait a little while and the program should appear on your computers
desktop (if you get an error you have probably forgotten to start Xming, so run it and try again).
1. If you want to run an X program, but still be able to use the same terminal console for other stuff,
you can run the command in the background with &:
i.e. leafpad &
Just remember that the more programs you run, the slower everything will get. You can switch to the
background program by typing fg, check for background jobs with bg.
2. You can even run a full desktop session through X-11, although it isnt particularly user-friendly and
VNC will produce better results. To do this you have to use lxsession instead of startx.
3. If you get the following error (or similar) when running PyGame or Tkinter scripts:

_tkinter.TclError: couldn't connect to display "localhost:10.0"


Use the fix below:

cd ~
sudo cp .Xauthority ~root/
More details and links are in the main Guide toRemote Connections
(http://pihw.wordpress.com/guides/guide-to-remote-connections/).

Additional Information / Troubleshooting


1. To switch on (or off) SSH you can access raspi config (just type sudo raspi-config from the
terminal) and select SSH in the menu (it seems like SSH is already enabled by default for some distros).
(http://pihw.files.wordpress.com/2013/03/ssh-raspi-config.png)
Enable/Disable SSH via Raspi-config
2. Ensure X-11 forwarding is enabled on the Raspberry Pi (again, a lot of distros now have this enabled
by default).
Use nano with the following command:

sudo nano /etc/ssh/sshd_config


Look for a line in the /etc/ssh/sshd_config file which controls X11Forwarding and ensure it says (with
no # before it):

X11Forwarding yes
Save if required (ctrl+x,Y, enter), and reboot:
sudo reboot

Using cmdline.txt for Other Network Settings


The ip= command-line option allows us to specify the network settings when the kernel is loaded (the
core of the linux system), its full options are in the following format (allows us to set every aspect of the
network if required):
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
More details of what each part means and other kernel options is detailed in section 2 of this kernel
documentation (https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt).

Easy Changing with a Simple Script:


The following script will prompt to allow you to change your settings (just type ./switchip.sh to run).
To create the file, you can use nano:

nano switchip.sh
Just press ctrl+x and y, to save and exit when you are done.
switchip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

#!/bin/sh
#Function to swap to Direct IP Address
direct () { sudo cp /boot/cmdline.direct /boot/cmdline.txt;}
#Function to swap to Normal Automatic IP Address
normal () { sudo cp /boot/cmdline.normal /boot/cmdline.txt;}
# Menu using case-esac
echo "Select IP Address? Use Direct or Auto or Keep (d/a/-)?"
read answer
case $answer in
d|D) echo Use Direct IP;direct;;
a|A) echo Use Auto IP;normal;;
*) echo Keep - No Change;;
esac
echo cmdline.txt
echo ____________

20

cat /boot/cmdline.txt

You could even extend this to allow you to setup fixed IP addresses for different networks, so you can
always be sure you can find your IP and connect correctly.

What is an IP Address / Hostnames / Pinging /


Subnets?
An IP Address is like your phone number or post code, it simply allows other computers to find that
particular computer in the network and ensure any messages it sends goes to that one in particular.
Often, IP Addresss can be replaced with hostnames so that we can ask for a specific computer without
knowing all the numbers (like the contacts list on your phone, the computer looks up the name and
uses the number for you). For instance, http://www.google.com (http://www.google.com), is a
hostname, where its IP address is 173.194.45.49 (probably depending on where you are). We can
ping the address using the following command, which simply sends some short messages to see if
there is another computer on the other side to respond to them.

ping www.google.com
or:

ping 173.194.45.49

Subnets:
Networks use subnets to help handle the fact that there could be a HUGE number of computers on a
network (like the internet) and it would be impossible for a computer to listen to and respond to any
computer in the address range 0.0.0.0 to 255.255.255.255.
To handle this, networks will use a subnet mask, this ensures that a computer only needs to respond to
computers with are within the same SUBSET, which is defined by the SUBNET MASK setting.
The mask is a series of flags which defines which range of addresses the computer will respond to (by
filtering out any which are not within the allowed range):

255.255.255.0
Means it will respond to computers which have IP addressing matching at least the 3 first numbers. So
a computer with an address of 192.168.1.90 and subnet mask of 255.255.255.0 will only talk to other
computers with addresses in the range 192.168.1.0-192.168.1.255 (except 90 of course!). Large networks
often use SUBNETs to split up larger networks into sections so that they run more efficiently.
Note: You will not be able to set the SUBNET MASK to wider than 255.0.0.0. The Raspberry Pi defaults
to a subnet mask of 255.255.0.0, which is perfect for most situations.

References:
Thanks to fellow MagPi - Colin Deady for testing out on Mac for me.
Thanks to the following sites for providing various parts of the puzzle (in no specific order):
www.kernel.org kernel documention
(https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt)
http://learn.adafruit.com/adafruits-raspberry-pi-lesson-6-using-ssh (http://learn.adafruit.com/adafruitsraspberry-pi-lesson-6-using-ssh)
http://people.arsc.edu/~murakami/xming/ (http://people.arsc.edu/~murakami/xming/)
http://jeremy-nicola.info/portfolio-item/ssh-x-forwarding-on-windows/ (http://jeremynicola.info/portfolio-item/ssh-x-forwarding-on-windows/)
http://en.wikipedia.org/wiki/Subnetwork (http://en.wikipedia.org/wiki/Subnetwork)
http://en.wikipedia.org/wiki/Link-local_address (http://en.wikipedia.org/wiki/Link-local_address)
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=22716
(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=22716)
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&t=24993
(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&t=24993)
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=26934
(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=26934)
Comments
supto says:
July 16, 2013 at 3:47 am
successful thank you very much and appreciate your awesome work which made our job very easy.
Reply
Direct Access Raspberry Pi Shell and Desktop on Laptop/PC without installing anything

extra on the Raspberry Pi OS or connecting it to a Display Unit | Syed Anwaarullah says:


July 16, 2013 at 7:42 am
[] http://pihw.wordpress.com/guides/direct-network-connection []
Reply
Direct Access Raspberry Pi Shell and Desktop on Laptop/PC without installing anything
on the Raspberry Pi OS or connecting it to a Display Unit | Syed Anwaarullah says:
July 16, 2013 at 7:28 pm
[] http://pihw.wordpress.com/guides/direct-network-connection []
Reply
Pingk says:
July 16, 2013 at 11:16 pm
I have RPis NOOBS 1.2 but having unzipped it, I cannot locate the cmdline.txt file anywhere
should I be using a different setup? Whats going wrong?
Reply
meltwater2000 says:
July 17, 2013 at 11:47 am
Ive not had chance to try NOOBS, I should be having a go with it next week.
Reply
Pingk says:
July 17, 2013 at 1:30 pm
Thanks! Take your time, youve done a great job with the tutorial thus far, very easy to
understand
Student says:
July 17, 2013 at 11:42 am
Hi meltwater, Ive followed your instructions and have got my pi running through my laptop
perfectly. I was just wondering since my ethernet port on my pi is now used for this, is there
anyway I can get internet access on my pi through my laptops wifi connection? If I try to bridge
my ethernet and wifi networks on my laptop (Windows 7) for internet access through ethernet, the
vnc server will no longer connect to my pi
Reply
meltwater2000 says:
July 17, 2013 at 11:48 am
Have a look at http://pihw.wordpress.com/2013/06/13/testers-required-super-easydirectnetwork-connection/ that should give you an idea on how to share the laptops internet
connection. Let me know if it works, so far no-one has said if it works or not (no news is good
news I guess).
Reply
Richard says:
July 23, 2013 at 9:28 pm
Yes, this configuration works just fine. You can do RPI software updates via the direct

Yes, this configuration works just fine. You can do RPI software updates via the direct
connected PC and the WiFi shared port. I find that some RPI programs like Leafpad do not
work under this connection option but I would only use this connection method for software
updates on the RPI anyway. Otherwise just use the direct connection mode. Oh yes, make
sure the PC ethernet port is not set to sharing as that run me around for a while. Tims
package works great.
Richard
Andrew Cluff says:
July 19, 2013 at 2:39 pm
hey my pi wont ping the laptop.
Reply
Aaron P says:
July 19, 2013 at 3:10 pm
Excellent walkthrough! Tried it with NOOBS but the cmdline.txt file does not exist. Downloaded the
newest Raspbian image from raspberrypi.org/downloads, imaged that to my SD card, let it start up
once all the way, turned it off and followed the directions on this page. Worked like a charm. No
hiccups. Xming works excellent for this. Thank you for the good writeup!
Reply
meltwater2000 says:
July 29, 2013 at 9:49 am
Yep, Ive yet to have chance to try NOOBS, I am hoping there is a similar way to specify the
start up command-line, there probably is just moved somewhere.
Reply
PiNE says:
July 24, 2013 at 2:18 pm
Hi Meltwater,
Got direct connection working (with PuTTY and UltraVNC) but the one thing that gave me
problems was pinging the W7 PC during the initial set up. The Pi sent packages but the PC did not
reply. Looking at The Network and Sharing Centre, the PC seemed to be receiving stuff, but was
not responding. Hmmm? Checking the PCs IP address, it showed 169.254.98.136.
Not important because Ive got the direct link working, but any ideas why the PC did not respond?
Cheers
Reply
meltwater2000 says:
July 29, 2013 at 9:38 am
Might be down to your default firewall settings perhaps, or sometimes it can get confused about
which connection to use (such as wifi). I think this is because it classes the direct link as a bad
link (there is no internet or router responding) it will respond on the other link instead.

Reply
Louis says:
July 28, 2013 at 3:31 pm
Im stuck, if followed the instructions, made sure everything is as identical as it can be (apart from ip
adresses) but when i open PuTTy is freezes, waits then says connections timed out
Reply
Louis says:
July 28, 2013 at 3:32 pm
A few typos: I open PuTTy it connection has
Reply
Louis says:
July 28, 2013 at 3:59 pm
Forget all that, it works now, but my question is now: how do you configure it to show the
programs/desktop?
Louis says:
July 28, 2013 at 4:51 pm
Finally got it all working, please ignore all my other posts
meltwater2000 says:
July 29, 2013 at 9:40 am
No problem, Linux can be very fussy about the text file format.
Les says:
July 29, 2013 at 9:01 am
Im hoping to use the Pi to collect data from inside a beehive. How would I link the Pi and a W7
laptop wirelessly, so that the laptop can control the Pi and collect the data?
Reply
meltwater2000 says:
July 29, 2013 at 9:35 am
Ive not had chance to experiment much with wifi links so far, but you may find some of the
solutions at the bottom of this post useful.
http://blogs.arcsoftwareconsultancy.com/pi/
Reply
Les says:
July 29, 2013 at 11:14 am
Ooops. Jumped before I was bitten. Picked up the ip from the Pi with ifconfig. Set the laptop to
the same network. Both had the same mask. Loaded putty on the laptopdone.
Apologies for being gormless.
Reply
meltwater2000 says:

July 29, 2013 at 11:23 am


No problem. Plenty of little things which can make it difficult until you get the idea. Glad it
works!
Magichsu says:
July 29, 2013 at 5:47 pm
To get a fixed IP addr, you can also find a file (path: etc->network->interfaces) on the SD card and
modify it with static IP addr such as following:
(for standard Ethernet connection)
iface eth0 inet static
address=192.168.0.xxx (this should be in the same subnet range as your computer)
netmask=xxx.xxx.xxx.xxx
Reply
NJ says:
August 13, 2013 at 1:42 pm
After adding the line with the ip address in the cmdline.txt nothing happens. The screen remains
blank. It also wont work with the serial connection after this. Removal of the line allows serial
connection once again. I used the same address as the one in the above and my computer, running
windows7, is and was configured to automatically assign ip addresses
Reply
NJ says:
August 13, 2013 at 2:33 pm
so I fixed my problem. I could be wrong but it seems you cant just generate your own ip
address. I connected the pi by network to the my computer(windows7) and then took the IPv4
address from its details in the network center(rough translation from win7 in French). Then I
wrote that into to the cmdline.txt file, booted up again and it work perfectly.
Thanks for the guide.
Reply
meltwater2000 says:
August 13, 2013 at 2:47 pm
The PC will typically set an IP address in the range 169.254.x.x when connected directly,
what IP address did you use? It must match the first two numbers the PC is set to.
Anyway glad it is working.
NJ says:
August 13, 2013 at 4:04 pm
It was within that range. I just didnt know how to go about retrieving it.
Reply
Sarge says:
August 14, 2013 at 11:51 pm

I wanted to thank you for the awesome instructions. I found myself in an isolated part of the coast of

I wanted to thank you for the awesome instructions. I found myself in an isolated part of the coast of
Maine without access to a monitor and keyboard. Although I had to drive 45 minutes to a Radio
Shack, I was able to pick-up a RJ45 cable and USB SD Card reader and implement the connection
instructions you provided.
This approach will be my travelling solution for setting up and running Raspberry Pi based
applications in the future. The SD Card reader, RJ45 cable, Pi and laptop are all going in the travel
bag.
I got great time-lapse photograps of sunsets this time. Not sure what might happen in the future.
Sarge
Reply
meltwater2000 says:
August 15, 2013 at 9:00 am
Thank you for sharing your excellent success! A tiny computer isnt so small if you need a
monitor to use it.
I would love to see the time-lapse you have produced.
Reply
Saravanan says:
August 16, 2013 at 10:16 am
I have a new pi.and I am using Ubuntu in my laptop.And configured the file in memory card and
all.Ubutu is set to automatic DHCP by default for wired connection.I switched on raspberry pi with
ethernet cable plugged in,The status LED is turned on in the pi.but I cannot establish connection
between pi and laptop(Connection fails all the time).I dont have a tv monitor orenything else to
connect with the pi help me.Do you have any video tutorials on youtube?
Reply
meltwater2000 says:
August 16, 2013 at 10:42 am
I did try to record a video, but it was taking too long to sort out.
Perhaps you can try using the .bat files which are in the
http://pihw.wordpress.com/guides/direct-network-connection/super-easy-direct-networkconnection/ post (even if you just use the CMDLINE.TXT file directly).
Unfortunately this will only work with a Raspbian image rather than the NOOBS system.
The common issues are:
1. Not using a linux compatible file editor on CMDLINE.TXT (ends up with extra characters
which shouldnt be in the file).
2. Having Wifi enabled on the Laptop when trying to connect (it tries to ping through that
rather than the LAN)
3. Ensure you wait for your LAN connection to finish detecting the direct connection (check the
status of your network device and that it has an IP given to it).

Fingers crossed that should help.


Reply
Saravanan says:
August 16, 2013 at 4:17 pm
I am using the latest raspian wheezy
liarlai says:
September 2, 2013 at 1:57 pm
hi
i have the same situation like Saravanan. first, i have follow your tutor on my laptop(win7),
and i used automaticly obtained ip address(ip=169.254.0.2), and this works perfectly like you
said(i left a reply below).
BUT, i re-installed my laptop to ubuntu(12.04), and without changing cmdline.txt of
rpi(ip=169.254.0.2), and i used putty to connect, but it didnt work.
and i noticed that 169.254.x.x is the default ip address of windows system when there is no
dhcp server for windows pc to connect to, and i suggest that the default ip address for
ubuntu is not 169.254.x.x. so i google it and i found out default ip address for ubuntu is
192.168.1.100~192.168.1.150(i am 100% NOT sure about this). so i changed ip address in
cmdline.txt to that range, but it didnt work so far, i dont know this info help or not, just let
you know. thanks again.
meltwater2000 says:
September 2, 2013 at 3:15 pm
169.254.x.x is a reserved range for direct LAN connections. 192.168.x.x is a common range
for local LAN connections.
You can check to see what gets allocated when you connect the LAN to your Ubuntu
machine, whatever gets allocated by Ubuntu when you directly connect a LAN cable to the
RPi should be the range you should use (ORyou can just force it by setting a fixed IP
address in Ubuntu, and then similar one in the correct range on the RPi it shouldnt care as
long as they are in the same range according to the netmask).
Saravanan says:
August 16, 2013 at 4:55 pm
still not working.I would appreciate a video tutorial on you tube with the essetials only.
Reply
LiarLai says:
August 19, 2013 at 7:07 am
i dont have HDMI monitor nor internet access, and i find your tutor. and it works perfectly for me.
thank you. first, i follow your instructions and it doesnt work, then i found out that i have edited my
cmdline.txt before, i deleted console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 this line for the
purpose of uart , so i recovered this line and it works just like you said.
can you tell me what is the connection between this line and the ethernet workings? thanks.
Reply
meltwater2000 says:

September 1, 2013 at 8:16 am


Not sure, it may just a bad character in the text perhaps. The file is very fussy since it is literally
dropped into the command line automatically run at boot, so anything which breaks the line or
nulls the line will mean it is ignored.
There may be something more to it, since tty was originally for serial, but then extended for
LAN etc, perhaps removing that just ends up disabling it (as nothing else is set up to use it). A
closer look at the commands may shed light on it otherwise.
Reply
David Briscoe says:
August 31, 2013 at 11:28 am
Hi,
I have a spare ethernet port on my main PC (the first/primary ethernet port is connected to an
ADSL router for internet access). Can I just plug my RasPi into this spare port and use set it up in
the same way? Will I be able to access the internet this way? Thanks.
Reply
meltwater2000 says:
September 1, 2013 at 8:11 am
Yes it should, Ive used a USB-LAN dongle to do just that. To get internet through to the RPi
you will need to use ICS (Internet Connection Sharing) to share to the 2nd LAN port (should be
similar to the wifi method).
Just watch that you can still ping it, and if required disable the other port until you get
connection with the RPi working, as windows sometimes tries connecting on the 1st port that is
valid.
Hopefully itll work well.
Reply
Randy Kibbe says:
September 5, 2013 at 10:18 pm
I went through the whole tutorial but when I try to connect through putty I get a connection
refused pop up. Am I doing something wrong?
Reply
meltwater2000 says:
September 5, 2013 at 10:23 pm
You will need to confirm that
a) The IP addresses are set correctly on both machines (if not check the cmdline.txt file)
b) You can ping between both machines (if not disable any other adaptors)
c) You dont have a firewall blocking SSH connections
Reply
Student says:
September 6, 2013 at 5:37 am
This connection error also happens if you try to connect through putty too soon after powering up
the pi, give the pi time to boot up!

Reply
F. Janes says:
September 16, 2013 at 9:09 pm
Hi Les,
Since Im very interested in Your project to gather data inside a bee hipe, did You succeed in doing
it?
Thanks
Aloha
Reply
techie009 says:
September 17, 2013 at 12:27 am
where can i find the file cmdline.txt ? I cant find it . i have a file named recovery.cmdline , I treid
editing this file and following the steps you mentioned, but it didnt work.
Reply
meltwater2000 says:
September 18, 2013 at 9:31 am
HI. You are using NOOBS, which makes this trick a little more difficult.
See the note on this page:
http://pihw.wordpress.com/guides/direct-network-connection/super-easy-direct-networkconnection/
Reply
techie009 says:
September 19, 2013 at 5:26 am
Hi, thanks for the reply. I tried doing the same as mentioned in the link, i meant using the
VM,but unfortunately I could not fine the cmdline.txt. Can you please help me with that.
Also yes I am using NOOBS.
meltwater2000 says:
September 19, 2013 at 9:40 am
When I connect it to my Debian VM, it has two mount points, including /media/boot.
Within there you will find the cmdline.txt file (which will get executed after the NOOBS
system has booted).
Hope that helps.
starcow123 says:
September 19, 2013 at 7:23 pm
PuTTY Fatal Error
Network error: Connectio timed out

Windows 8-64bit

Windows 8-64bit
Raspberry Pi Model B
Standard ethernet cable (not crossover)
Using PuTTY and Xming
First boot on Raspberry Pi on Raspbian
in SD root file system I only have cmdline.normal
HELP?
Reply
meltwater2000 says:
September 19, 2013 at 7:31 pm
You need cmdline.txt in there. cmdline.normal / cmdline.direct etc are example files (and used
by the bat script to change cmdline.txt). You want to make cmdline.txt match cmdline.direct for
direct connections.
Reply
Saravanan says:
September 20, 2013 at 8:56 am
Can you write a tutorial on X11 forwarding in ubuntu/linux.I can now access the command line of
pi only.
Reply

Blog at WordPress.com. | The Greyzed Theme.

Das könnte Ihnen auch gefallen