LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Tethering Android phone to Linux to PS3 (https://www.linuxquestions.org/questions/linux-newbie-8/tethering-android-phone-to-linux-to-ps3-846117/)

SantaClawZ 11-23-2010 04:56 PM

Tethering Android phone to Linux to PS3
 
I am running ubuntu 10.10 and supplying my internet connection with EasyTether on my Motorola Droid 2. I've got my laptop internet working great, but I've tried to follow a couple connection sharing guides and they don't seem to work with my PS3. So the setup is that EasyTether provides the internet connection and an ethernet cable connects the laptop and ps3. I have even tried using FireStarter, but it says eth0 (the connection between laptop and ps3) is not ready.

So here's the question: What should I do to allow my ps3 to access the internet? I've tried manual and automatic settings on my ps3 and neither worked. I believe the problem is with my laptop's settings.

Here's what happens when I do a connection test on my PS3 (automatic config)

Obatain IP Address - Failed

And when I do it manually

Obtain IP Address - Succeeded
Internet Connection - Failed


I'm fairly new to Linux, so please answer in newbie terms.

Dark_Helmet 11-23-2010 06:12 PM

I might be able to help you out a little more :)

Ok, I don't have a ps3. So I'm a little handicapped in knowing how/what to do with it to accomplish certain tasks.

Quote:

Here's what happens when I do a connection test on my PS3 (automatic config)

Obatain IP Address - Failed
This means that the ps3 cannot find a DHCP server. That's true unless you're running one on your laptop. And if you are running one, you probably know it :) A DHCP server is not hard to install or run. So if you want, I can help with that.

If you don't want to run a DHCP server, we need to set the ps3 to use a static IP or go through the manual config as you mentioned.

First, go to your laptop, open a terminal, and execute ifconfig. Your laptop should have at least three network connections (if you're connected through easytether):
1. eth0
2. lo
3. easytether0

Ignore the lo and easytether0 interfaces and focus on the eth0. Find the second line of the information for eth0. It should look something like this:
Code:

          inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0
Your addresses can vary of course.

So you need to configure the ps3 to use an IP address in the same network. With the above output, 192.168.0.202 would work.

You may need to give the ps3 a netmask value (e.g. 255.255.255.0)

Now you need to tell the ps3 what gateway to use. If the ps3 has an option for that, use your laptop's IP address (e.g. 192.168.0.101).

If there is no gateway option, then the ps3 probably assumes the gateway is 192.168.0.1. In that case, you need to reconfigure your laptop to use 192.168.0.1 for it's IP address.

Then setup connection sharing on the laptop. The simplest way would be:
1. disable your laptop's firewall entirely (just for testing--craft an appropriate firewall later)
2. execute the following commands:
Code:

sudo su -
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o easytether0 -j MASQUERADE
exit

Then try connecting with the ps3.

SantaClawZ 11-23-2010 11:21 PM

Quote:

Originally Posted by Dark_Helmet (Post 4168736)
First, go to your laptop, open a terminal, and execute ifconfig. Your laptop should have at least three network connections (if you're connected through easytether):
1. eth0
2. lo
3. easytether0

Ignore the lo and easytether0 interfaces and focus on the eth0. Find the second line of the information for eth0. It should look something like this:
Code:

          inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0
Your addresses can vary of course.

eth0 shows no 'inet addr' ; 'Bcast' ; or 'Mask' even though my laptop is online and my ps3 is turned on.

Also, if this info helps, the following can be modified on ps3
Code:

IP Address (static IP)
Subnet Mask
Default Router
Primary DNS
Secondary DNS
Network Router Speed and Duplex
MTU
UPnP


dudeman41465 11-24-2010 12:10 AM

Firestarter is an old firewall program. Not sure if it's still being actively updated, but it's still in the Ubuntu repos and has built-in options for connection sharing and DHCP serving on individual interfaces so you wouldn't have to necessarily assign a static IP to the PS3.

Dark_Helmet 11-24-2010 12:12 AM

Ok, that explains it.

Your laptop is probably configured to use DHCP for eth0. The only way you don't have an IP address for eth0 is if the DHCP request failed. In this case, it would seem clear that you don't have a DHCP server that assigns an IP address to the laptop.

Ok, so we'll do a temporary setup. This setup won't survive a reboot, but I'll explain that a little later.

So, on your laptop, execute the following commands in a terminal:
Code:

sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
ifconfig

Verify that the ifconfig output gives this line for eth0:
Code:

          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
Then, set up your ps3 like this:
IP Address (static IP): 192.168.0.10
Subnet Mask: 255.255.255.0
Default Router: 192.168.0.1

The ps3 address can be anything of the form 192.168.0.??? except for 0, 1, and 255.

You shouldn't need to configure the DNS I don't think, but if you do, copy them from the easytether connect output. That should be:
Primary DNS: 8.8.8.8
Secondary DNS: 8.8.4.4

Now, jump back to my previous post for the quick-and-dirty connection sharing. Follow those steps, and try connecting with the ps3.

Follow-up on the temporary setup.
I mentioned that I would come back to it... I suggest the temporary setup because I don't know how you use your laptop. You could have eth0 configured for DHCP for a specific reason, or it could be that way because the Ubuntu install defaults to DHCP. I didn't want to make a change that might otherwise break another use for the laptop (e.g. work). At least this way, you're only a reboot away from getting your default settings back.

EDIT:
Quote:

eth0 shows no 'inet addr' ; 'Bcast' ; or 'Mask' even though my laptop is online and my ps3 is turned on
Just to touch on the "laptop is online" part... When you connect to the smartphone, it's as though you're adding another network card on-the-fly. That's the easytether0 interface. So, when your laptop wanted to connect to the Internet, it had two paths: eth0 and easytether0. The eth0 path was "broken" because no network information was configured. So the system defaults to the easytether0 interface--which then transferred the data like you would expect.

That brings up one other issue we may need to address. After you verify that eth0 has an IP address with the ifconfig command, also execute the following and paste the output:
Code:

sudo route
Linux may create a default gateway pointing to eth0 after you bring up the interface. That will probably break things, but it can be fixed. the route command will tell us if it does.

SantaClawZ 11-24-2010 12:21 AM

It STILL does the same thing. Also firestarter returns the error "device eth0 is not ready"

I believe we've narrowed the problem down to the actual connection between the laptop and ps3, all the settings seem to be correct other than that.

Dark_Helmet 11-24-2010 02:06 AM

Our posts went up about the same time. So I don't know if you were responding to dudeman41465 or me.

I didn't see you post the output of the route command at the end of my last post. So I assumed you hadn't tried out my suggestions.

So, just to be thorough, let's step through this. If one of the steps says to verify something, and it does not match what you see, please post the command you issued and the output. Also, I'm not familiar with firestarter, but please disable it for the time being.
  1. Start by powering down everything: ps3, laptop, and disconnect your smartphone.
  2. Turn on your laptop.
  3. After it boots, open a terminal
  4. Execute ifconfig
  5. Verify that you have two interfaces: eth0 and lo
  6. Verify that eth0 does not have an inet addr, Bcast, or Mask
  7. Execute sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
  8. Execute ifconfig
  9. Verify that eth0 does have an inet addr, Bcast, and Mask
    inet addr:192.168.0.1
    Bcast: 192.168.0.255
    Mask: 255.255.255.0
  10. Execute:
    Code:

    sudo su -
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -o easytether0 -j MASQUERADE
    exit

  11. Execute route
  12. Verify that the output looks something like:
    Code:

    Kernel IP routing table
    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
    default        ???            0.0.0.0        UG    0      0        0 eth0

    There will probably be other lines. The line with "default" is what we're concerned with. The gateway field could be an IP address, it could be "localhost," the machine name, etc. We're not concerned with that--only that there is a default route and that the default route is associated with eth0.
  13. Now connect the smartphone and kick off the connection script (if you haven't already set up udev)
  14. Execute route
  15. Verify that there is a new "default" entry:
    Code:

    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
    default        192.168.117.1  0.0.0.0        UG    0      0        0 easytether0

    Gateway may be a little different based on what your phone gives you.
  16. Verify that you can connect to the Internet however you like (web browser, email, irc, whatever)
  17. Make sure the ethernet cable between the ps3 and laptop is secure, and turn on the ps3
  18. Manually configure the ps3:
    IP Address: 192.168.0.10
    Subnet Mask: 255.255.255.0
    Default Router: 192.168.0.1
    Primary DNS: 8.8.8.8
    Secondary DNS: 8.8.4.4

Hopefully that will get you connected. If not, do some additional testing for me:
  1. Execute ping 192.168.0.10
  2. Verify that your output is something like:
    Code:

    PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data.
    64 bytes from 192.168.0.10: icmp_seq=1 ttl=64 time=0.281 ms
    64 bytes from 192.168.0.10: icmp_seq=2 ttl=64 time=0.267 ms

  3. Press Control-C to kill the ping command
  4. Execute sudo iptables --list
    You might get a boatload of output. Here is what I get on a machine with no firewall running. The main thing is that all "Chains" have a "policy ACCEPT."
    Code:

    Chain INPUT (policy ACCEPT)
    target    prot opt source              destination       

    Chain FORWARD (policy ACCEPT)
    target    prot opt source              destination       

    Chain OUTPUT (policy ACCEPT)
    target    prot opt source              destination


Let me know how it goes.

SantaClawZ 11-27-2010 08:31 PM

Quote:

Originally Posted by Dark_Helmet (Post 4169148)
Our posts went up about the same time. So I don't know if you were responding to dudeman41465 or me.

I didn't see you post the output of the route command at the end of my last post. So I assumed you hadn't tried out my suggestions.

So, just to be thorough, let's step through this. If one of the steps says to verify something, and it does not match what you see, please post the command you issued and the output. Also, I'm not familiar with firestarter, but please disable it for the time being.
  1. Start by powering down everything: ps3, laptop, and disconnect your smartphone.
  2. Turn on your laptop.
  3. After it boots, open a terminal
  4. Execute ifconfig
  5. Verify that you have two interfaces: eth0 and lo
  6. Verify that eth0 does not have an inet addr, Bcast, or Mask
  7. Execute sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
  8. Execute ifconfig
  9. Verify that eth0 does have an inet addr, Bcast, and Mask
    inet addr:192.168.0.1
    Bcast: 192.168.0.255
    Mask: 255.255.255.0
  10. Execute:
    Code:

    sudo su -
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -o easytether0 -j MASQUERADE
    exit

  11. Execute route
  12. Verify that the output looks something like:
    Code:

    Kernel IP routing table
    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
    default        ???            0.0.0.0        UG    0      0        0 eth0

    There will probably be other lines. The line with "default" is what we're concerned with. The gateway field could be an IP address, it could be "localhost," the machine name, etc. We're not concerned with that--only that there is a default route and that the default route is associated with eth0.
  13. Now connect the smartphone and kick off the connection script (if you haven't already set up udev)
  14. Execute route
  15. Verify that there is a new "default" entry:
    Code:

    Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
    default        192.168.117.1  0.0.0.0        UG    0      0        0 easytether0

    Gateway may be a little different based on what your phone gives you.
  16. Verify that you can connect to the Internet however you like (web browser, email, irc, whatever)
  17. Make sure the ethernet cable between the ps3 and laptop is secure, and turn on the ps3
  18. Manually configure the ps3:
    IP Address: 192.168.0.10
    Subnet Mask: 255.255.255.0
    Default Router: 192.168.0.1
    Primary DNS: 8.8.8.8
    Secondary DNS: 8.8.4.4

Hopefully that will get you connected. If not, do some additional testing for me:
  1. Execute ping 192.168.0.10
  2. Verify that your output is something like:
    Code:

    PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data.
    64 bytes from 192.168.0.10: icmp_seq=1 ttl=64 time=0.281 ms
    64 bytes from 192.168.0.10: icmp_seq=2 ttl=64 time=0.267 ms

  3. Press Control-C to kill the ping command
  4. Execute sudo iptables --list
    You might get a boatload of output. Here is what I get on a machine with no firewall running. The main thing is that all "Chains" have a "policy ACCEPT."
    Code:

    Chain INPUT (policy ACCEPT)
    target    prot opt source              destination       

    Chain FORWARD (policy ACCEPT)
    target    prot opt source              destination       

    Chain OUTPUT (policy ACCEPT)
    target    prot opt source              destination


Let me know how it goes.

I haven't been available all week, I'm just now about to start this. I'll tell you what happens at each step.

EDIT:

1. done
2. done
3. done
4. done
5. eth0, lo, and wlan0
6. no inet addr, bcast, or mask
7. done
8. done
9. matches up; done
10. done
11. done
12. output
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.0.0    *              255.255.255.0  U    0      0        0 eth0

13. done
14. done
15. output
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.117.0  *              255.255.255.0  U    0      0        0 easytether0
192.168.0.0    *              255.255.255.0  U    0      0        0 eth0
default        192.168.117.1  0.0.0.0        UG    0      0        0 easytether0

16. done
17. done
18. done - ip address obtained - internet connection failed

Side note: The inet addr, bcast, and mask disappear once the ps3 is powered on. I had to run the command again to assign those values, and then I ran ifconfig again to make sure they stayed.

1. done
2. ping failed (no return)
3. done
4. output
Code:

Chain INPUT (policy ACCEPT)
target    prot opt source              destination       

Chain FORWARD (policy ACCEPT)
target    prot opt source              destination       

Chain OUTPUT (policy ACCEPT)
target    prot opt source              destination

EDIT:

Here's the output of route after I powered on the ps3 and assigned the values
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.117.0  *              255.255.255.0  U    0      0        0 easytether0
192.168.0.0    *              255.255.255.0  U    0      0        0 eth0
default        192.168.117.1  0.0.0.0        UG    0      0        0 easytether0

The problems seem to begin to appear in the first route command

I checked in about 5 minutes later with ifconfig and inet addr, bcast, and mask of eth0 were gone. I also used route and eth0 was absent from the list.

Dark_Helmet 11-27-2010 11:51 PM

Quote:

5. eth0, lo, and wlan0
That's fine. I didn't realize you had a wireless interface.

Quote:

12. output
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.0.0    *              255.255.255.0  U    0      0        0 eth0


That's ok too. I thought it would create a default route automatically, but this entry is fine.

Quote:

Side note: The inet addr, bcast, and mask disappear once the ps3 is powered on. I had to run the command again to assign those values, and then I ran ifconfig again to make sure they stayed.
Ok, that confused me at first. What kind of cable are you using to connect the ps3 with the laptop? Are you using a crossover or straight-through cable? You need a crossover cable. If you're using a straight-through, that would probably explain why Linux drops the network information for eth0--it detects a conflict on what drives the signal on wires that Linux expects to be exclusively under its control.

I don't know if you're familiar with the difference, but a store-bought ethernet cable is 90% likely to be a straight-through cable. If you're not sure, you can check yourself. Compare each connector of the cable--have the "clip" face away from you so that you're looking directly at the metal contacts on each connector. Try to identify the coloring of each wire running to each metal contact. If both connectors have the same colored wire running to the same metal contact, then you have a straight-through cable.

It's common practice that the wire colorings are arranged this way (but it's not a requirement) from left to right:
Code:

white with orange stripe
solid orange
white with green stripe
solid blue
white with blue stripe
solid green
white with brown stripe
solid brown

Like I said, you'll need to use a crossover cable (which switches the four wires that have orange and green as part of their coloring).

If you have an unused hub or switch, you can avoid getting a crossover cable by plugging the laptop and the ps3 into the hub/switch--the hub/switch handles the necessary wire translation for you internally.

If you have a crossover cable and are still having this problem, then I'll need to research to find out if the ps3 is doing something funky when it starts up.

SantaClawZ 11-28-2010 02:44 PM

Quote:

Originally Posted by Dark_Helmet (Post 4173233)
That's fine. I didn't realize you had a wireless interface.


That's ok too. I thought it would create a default route automatically, but this entry is fine.


Ok, that confused me at first. What kind of cable are you using to connect the ps3 with the laptop? Are you using a crossover or straight-through cable? You need a crossover cable. If you're using a straight-through, that would probably explain why Linux drops the network information for eth0--it detects a conflict on what drives the signal on wires that Linux expects to be exclusively under its control.

I don't know if you're familiar with the difference, but a store-bought ethernet cable is 90% likely to be a straight-through cable. If you're not sure, you can check yourself. Compare each connector of the cable--have the "clip" face away from you so that you're looking directly at the metal contacts on each connector. Try to identify the coloring of each wire running to each metal contact. If both connectors have the same colored wire running to the same metal contact, then you have a straight-through cable.

It's common practice that the wire colorings are arranged this way (but it's not a requirement) from left to right:
Code:

white with orange stripe
solid orange
white with green stripe
solid blue
white with blue stripe
solid green
white with brown stripe
solid brown

Like I said, you'll need to use a crossover cable (which switches the four wires that have orange and green as part of their coloring).

If you have an unused hub or switch, you can avoid getting a crossover cable by plugging the laptop and the ps3 into the hub/switch--the hub/switch handles the necessary wire translation for you internally.

If you have a crossover cable and are still having this problem, then I'll need to research to find out if the ps3 is doing something funky when it starts up.


Thanks for the help :D I'm going to order a Crossover Cable later today
I was just using a random CAT6 cable I picked up from an unused fax machine

Also, would you recommend a CAT5e or CAT6 crossover, or will there be no difference?

Dark_Helmet 11-28-2010 06:23 PM

If you've got plans to use the cable at gigabit speeds now or in the future, then get CAT6. Otherwise, save the cash and get CAT5e.

If the only use for the cable is this connection sharing, then you want CAT5e because the phone certainly can't push gigabit speed. In fact, the best speed I've seen peaked at 200 KB/s. And that's well below 10 Mb/s.

SantaClawZ 12-02-2010 12:43 PM

I just got my crossover cable and I get pretty much the same results. In ifconfig the eth0's inet addr, bcast, and mask disappear after a while, and the ping fails.

I even tried turning on my ps3 before doing this entire process and it won't work

Dark_Helmet 12-02-2010 04:08 PM

Quote:

Originally Posted by SantaClawZ
I just got my crossover cable and I get pretty much the same results. In ifconfig the eth0's inet addr, bcast, and mask disappear after a while, and the ping fails.

Well... When you say "pretty much the same results" was there anything else different beyond the inet addr, bcast, mask, and ping?

At this point, I have to ask: after your initial install of Ubuntu, did you change network settings or install any network software?

We'll try something else though. I'm about to give you instructions to configure your wired network interface to use a static IP address. My thinking is that maybe your DHCP client (if you're set up that way) is interfering with the temporary network settings we're using with the ifconfig commands.

Take a look at /etc/network/interfaces

It should look something like this:
Code:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Make a backup copy of the file. Now, make some changes (you will need root privileges--so you'll have to launch an editor with sudo). Make it look like this:
Code:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

Now reboot. After you reboot, run ifconfig. The output should show the correct inet addr, bcast, and mask automatically.

Note: If something goes wrong, you can go back to your original network configuration by restoring your backup copy.

Keep an eye on the settings--see if the interface spontaneously drops them. If the settings stick, try running through the process again. You can skip steps 4-9.

SantaClawZ 12-02-2010 09:40 PM

Quote:

Originally Posted by Dark_Helmet (Post 4178760)
Well... When you say "pretty much the same results" was there anything else different beyond the inet addr, bcast, mask, and ping?

At this point, I have to ask: after your initial install of Ubuntu, did you change network settings or install any network software?

We'll try something else though. I'm about to give you instructions to configure your wired network interface to use a static IP address. My thinking is that maybe your DHCP client (if you're set up that way) is interfering with the temporary network settings we're using with the ifconfig commands.

Take a look at /etc/network/interfaces

It should look something like this:
Code:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Make a backup copy of the file. Now, make some changes (you will need root privileges--so you'll have to launch an editor with sudo). Make it look like this:
Code:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

Now reboot. After you reboot, run ifconfig. The output should show the correct inet addr, bcast, and mask automatically.

Note: If something goes wrong, you can go back to your original network configuration by restoring your backup copy.

Keep an eye on the settings--see if the interface spontaneously drops them. If the settings stick, try running through the process again. You can skip steps 4-9.


That fixed it, thanks :)

Dark_Helmet 12-02-2010 10:10 PM

Great news!

If you feel like tempting fate, you can make the other commands permanent by editing some config files on your laptop.

To make it so you don't need to enter echo 1 > /proc/sys/net/ipv4/ip_forward everytime:

Edit /etc/sysctl.conf (you'll need root privileges)

Find this block of text, delete the hash mark in red, and save the file:
Code:

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1



To make it so you don't need to enter iptables -t nat -A POSTROUTING -o easytether0 -j MASQUERADE everytime:

Edit /etc/rc.local (you'll need root privileges)

Here's a full copy of my rc.local. Yours should be the same, except for the line in green--which you'll add:
Code:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

iptables -t nat -A POSTROUTING -o easytether0 -j MASQUERADE

exit 0

EDIT:
If you setup firewall software, realize that the above change may not work with all firewall configuration tools. Based on the setup we've done, you probably want to focus on protecting the easytether0 interface rather than eth0.

Once you make the above changes, you should be good to go. Just flip on the laptop, connect the phone (if you've got udev setup), and setup the ps3. It should be virtually hands-free--depending on whether the ps3 remembers the network settings after cycling the power.


All times are GMT -5. The time now is 06:12 AM.