Getting Internet over g_ether and Linux host?


patrick295767

Member
Joined
Jan 10, 2013
Messages
223
Hi,

I plug over the usb 1.0 the pandora to a debian linux machine. 

1) On pandora:

 modprobe g_ether

 ifconfig -a  gives right the usb0 !!

2) On Debian, I give to /etc/network/interfaces

iface usb0 inet static

  address 192.168.1.1

  network 192.168.1.0

  netmask 255.255.255.0

  broadcast 192.168.1.255

lsmod on debian is ok

and ifconfig gives well  ifconfig -a: 

  usb0

3) What else? 

On pandora :  

ifconfig usb0 192.168.1.15 

and then dhclient usb0

does not give Internet.

Any help would be greatly appreciated.

Regards
 
Figured this would get a bit more love if I moved this to the support section instead of the development section.
 
 
On your debian machine make the usb0 stanza like this in /etc/network/interfaces:

allow-hotplug usb0

iface usb0 inet static

  address 192.168.1.1

  network 192.168.1.0

  netmask 255.255.255.0

  broadcast 192.168.1.255

  up iptables -A POSTROUTING -t nat -s 192.168.1.0/25 -j MASQUERADE

  up echo 2 > /proc/sys/net/ipv4/ip_forward

  down iptables -A POSTROUTING -t nat -s 192.168.1.0/25 -j MASQUERADE

 

Now, reconnect the USB connector to your pandora to reload this config, and verify with ifconfig if the ip address is set.

 

On your pandora, do:

ifconfig usb0 192.168.1.15

route add default gw 192.168.1.1

 

Now, you should be able to ping ip addresses on the internet, but not hostnames (ping 4.2.2.2 should work).

To get DNS working do on your debian machine:

cat /etc/resolv.conf

 

you should get a line something like:

nameserver 4.2.2.2

then copy that line and add it to your pandora like this:

echo nameserver 4.2.2.2 | sudo tee /etc/resolv.conf

 

Now, you should be able to ping google.com and surf and have fun.

This could be automated if you on your pandora added these lines to your /etc/network/interfaces (on your PANDORA, not your debian machine)

 

allow-hotplug usb0

iface usb0 inet static

  address 192.168.1.15

  network 192.168.1.0

  netmask 255.255.255.0

  broadcast 192.168.1.255

  gateway 192.168.1.1

  up echo nameserver 4.2.2.2 > /etc/resolv.conf

 

Replace the IP after nameserver with what you got earlier on your debian machine.

Now, you just need to load the ethernet module and plug and play.

 

Hope this helps.

Have fun!

 

Edit: you can also have a setup with dnsmasq which gives you IP and stuff automatically, but it's a bit more complicated and i'm too lazy to explain how to do it.
 
Last edited by a moderator:
Hi

Although it is a very complete answer proposal...

So I have added to the server debian the lines to the interface.

Ifconfig gives good things:


eth0      Link encap:Ethernet  HWaddr xx
          inet addr:192.168.1.x  Bcast:192.168.1.255  Mask:255.255.255.0
xx
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2164365 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2370434 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1269861147 (1.1 GiB)  TX bytes:1926016420 (1.7 GiB)
          Interrupt:11


lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:115864 errors:0 dropped:0 overruns:0 frame:0
          TX packets:115864 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:10222798 (9.7 MiB)  TX bytes:10222798 (9.7 MiB)


usb0      Link encap:Ethernet  HWaddr xx
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
  xx
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:65 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3326 (3.2 KiB)  TX bytes:468 (468.0

I do on the pandora:


modprobe g_ether

and then 




ifconfig usb0 192.168.1.15
worked.

Then




route add default gw 192.168.1.1


But ping 192.168.1.2 does not work (onto a active pc).

On the pandora the ifconfig gives well the usb0 into the ifconfig -a with hte right 192.xxx.15.

However the ping does not work :(

what should I do? what would you advice?
 
Last edited by a moderator:
Back
Top