Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Internet connection sharing setup
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
moult
Retired Dev
Retired Dev


Joined: 31 Mar 2008
Posts: 146
Location: Australia

PostPosted: Sat May 11, 2013 9:49 pm    Post subject: Internet connection sharing setup Reply with quote

Hey all, I'm absolutely pathetic at networks so hopefully someone can point me in the right direction.

I've got a laptop connected via wlan0 to a 3G modem. It connects to the internet without any issues. Connected to it via eth1 using an ethernet cable is a beaglebone (think raspberry pi) running angstrom linux. on the network, it's known as 192.168.7.2. it currently cannot connect to the internet:

Code:
root@beaglebone:~# ping 88.198.98.200
PING 88.198.98.200 (88.198.98.200) 56(84) bytes of data.
From 169.254.149.95 icmp_seq=1 Destination Host Unreachable
From 169.254.149.95 icmp_seq=2 Destination Host Unreachable
From 169.254.149.95 icmp_seq=3 Destination Host Unreachable
From 169.254.149.95 icmp_seq=4 Destination Host Unreachable
^C
--- 88.198.98.200 ping statistics ---
6 packets transmitted, 0 received, +4 errors, 100% packet loss, time 5009ms
pipe 4


And so I'm trying to set up internet connection sharing so it can use my laptop's internet. From the beaglebone, I can connect to my laptop via sshing to 192.168.7.1.

This is ifconfig on the beaglebone:

Code:
root@beaglebone:~# ifconfig
eth0      Link encap:Ethernet  HWaddr C8:A0:30:A6:E8:9E
          inet addr:169.254.149.95  Bcast:169.254.255.255  Mask:255.255.0.0
          inet6 addr: fe80::caa0:30ff:fea6:e89e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:15773 (15.4 KiB)
          Interrupt:56

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:65536  Metric:1
          RX packets:52 errors:0 dropped:0 overruns:0 frame:0
          TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5488 (5.3 KiB)  TX bytes:5488 (5.3 KiB)

usb0      Link encap:Ethernet  HWaddr BE:56:25:71:00:46
          inet addr:192.168.7.2  Bcast:192.168.7.3  Mask:255.255.255.252
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1816 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1129 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:137849 (134.6 KiB)  TX bytes:195380 (190.8 KiB)


and this is ifconfig on my laptop:

Code:
moult dion # ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::221:ccff:fe70:212  prefixlen 64  scopeid 0x20<link>
        ether 00:21:cc:70:02:12  txqueuelen 1000  (Ethernet)
        RX packets 132  bytes 29648 (28.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 1004 (1004.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf5200000-f5220000

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.7.1  netmask 255.255.255.252  broadcast 192.168.7.3
        inet6 fe80::caa0:30ff:fea6:9890  prefixlen 64  scopeid 0x20<link>
        ether c8:a0:30:a6:98:90  txqueuelen 1000  (Ethernet)
        RX packets 1155  bytes 133698 (130.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1845  bytes 246559 (240.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 36122  bytes 3264592 (3.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 36122  bytes 3264592 (3.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::3a59:f9ff:fee1:92fd  prefixlen 64  scopeid 0x20<link>
        ether 38:59:f9:e1:92:fd  txqueuelen 1000  (Ethernet)
        RX packets 54279  bytes 42408319 (40.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 77895  bytes 9970485 (9.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


And this is route -n on my laptop:

Code:
dion@moult ~ $ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    305    0        0 wlan0
127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
192.168.0.0     0.0.0.0         255.255.255.0   U     305    0        0 wlan0
192.168.7.0     0.0.0.0         255.255.255.252 U     8      0        0 eth1


I have run (and tried both with iptables started and stopped):

Code:
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE


and to enable ip forwarding (yes, I have CONFIG_IP_ADVANCED_ROUTER enabled in kernel)

Code:
echo 1 > /proc/sys/net/ipv4/ip_forward


Still can't ping any internet site on the beaglebone. Any ideas?
_________________
thinkMoult - I write articles online. You might like some of them.
Planet Larry - do you write a blog and use Gentoo? Get your blog added to the Planet Larry Gentoo user blog aggregator!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54218
Location: 56N 3W

PostPosted: Sat May 11, 2013 10:07 pm    Post subject: Reply with quote

Moult,

You can either set your laptop up as a router
I suppose you have Gentoo there :)

Or you can run PPP between the laptop and beaglebone and give both endpoints addresses in the 192.168.0.0/24 subnet.
Then it will all JustWork. You will need a script to start PPP on the laptop. This is what I used to do or my iPaq.

Code:
root@beaglebone:~# ping 88.198.98.200
PING 88.198.98.200 (88.198.98.200) 56(84) bytes of data.
From 169.254.149.95 ...
says the beaglebone has the link-local IP of 169.254.149.95, which is not what you claimed
Moult wrote:
it's known as 192.168.7.2

At least, at the time of the ping you posted, it had the IP address of 169.254.149.95. ssh would not work like that, so something in the data set is not self consistent.

-- edit --
Reading more carefully, the ping is going out of eth0 on the beaglebone, you need it to go over usb0.
That suggests the default route on the beaglebone is via eth0, not usb0
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
moult
Retired Dev
Retired Dev


Joined: 31 Mar 2008
Posts: 146
Location: Australia

PostPosted: Sat May 11, 2013 10:29 pm    Post subject: Reply with quote

Hi neddy,

Thanks for your fast reply. The beagle is connected via eth1 and usb0 to the laptop. The usb powers it and the eth allows me to connect to it (i hadn't worked out how to do Internet over usb). I say 192.168.7.2 because that's the ip I ssh to if I want to connect to the beagle from my laptop. So yes, the ping is going through eth and not usb. I thought that was the way it should be? Or am I misunderstanding something?

Also, if I am on the beagle, I can ssh back into the laptop by sshing into 192.168.7.1. Hopefully that helps explain something.

As for the solutions you suggested, I think ppp would be easier than a router. Have you got a guide for that?
_________________
thinkMoult - I write articles online. You might like some of them.
Planet Larry - do you write a blog and use Gentoo? Get your blog added to the Planet Larry Gentoo user blog aggregator!
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Sat May 11, 2013 11:01 pm    Post subject: Reply with quote

As Neddy says, the Ethernet interface on the Beaglebone has not received a valid address via DHCP, so it assigned one via APIPA. The USB interface does have a valid address, which is how you are able to ssh to and from the device. For any address on the same subnet as the address assigned to usb0, the device will prefer using usb0, which is why it can answer your ssh connection from the laptop and why it can ssh to the laptop. However, for any other address, it will rely on the default route, which appears to have been set to eth0. Since eth0 is not configured to route traffic properly, this means the traffic fails.

You have two options. We can change the routing table to prefer usb0, so that both subnet-local and general traffic is sent over USB. We could try to fix eth0 so that you can pass traffic over it. For the former, please try ip route del default ; ip route add default via 192.168.7.1. For the latter, you would need to arrange to provide DHCP service when eth0 requests an address.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54218
Location: 56N 3W

PostPosted: Sat May 11, 2013 11:15 pm    Post subject: Reply with quote

Moult,

Before dipping into PPP, your ping is clearly going out from eth0 as
Code:
# ping 88.198.98.200
PING 88.198.98.200 (88.198.98.200) 56(84) bytes of data.
From 169.254.149.95 ...
and
Code:
root@beaglebone:~# ifconfig
eth0      Link encap:Ethernet  HWaddr C8:A0:30:A6:E8:9E
          inet addr:169.254.149.95  Bcast:169.254.255.255  Mask:255.255.0.0

usb0      Link encap:Ethernet  HWaddr BE:56:25:71:00:46
          inet addr:192.168.7.2  Bcast:192.168.7.3  Mask:255.255.255.252
so the beaglebone knows about usb networking.
On your laptop
Code:
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.7.1  netmask 255.255.255.252  broadcast 192.168.7.3

Nice to see the subnetting is right, even if it is nonstandard.
Those two systems cannot communicate on the 192.168.7.0/30 subnet. What does route on the beaglebone look like?

For PPP you need PPP support both ends and a script something like - this runs PPP over USB (I had forgotten that)
Code:
#!/bin/bash
#
# ipaqnet       Control script for iPAQ USBNet connection
#
# Author: Michel Stempin
# Creation: 11/08/2002

# additional comments and minor tweaks
# Roy Bamford 6 Dec 2003

PC_ADDR=192.168.100.201
IPAQ_ADDR=192.168.100.202
IPAQ_NET=192.168.100.0/24

# WARNING:usb0 is hard coded in some places
UPLINK_IF=usb0

start() {
    # load the usb networking module
    /sbin/modprobe usbnet
   
    # bring up the PC end of the link with IP addr PC_ADDR
    # exit if it fails for some reason
    /sbin/ifconfig usb0 inet $PC_ADDR up
    if [ $? -ne 0 ]; then
        echo "Could not set up usb0"
        echo "Is the iPaq connected and switched on?"
        exit 1
    fi
 
    # set up proxy_arp for our usb interface
    echo "1" >/proc/sys/net/ipv4/conf/usb0/proxy_arp
    UPLINK=`/sbin/ifconfig $UPLINK_IF >/dev/null 2>&1`
    # exit if it fails for some reason
    if [ $? -ne 0 ]; then
        echo "Could not set up proxy_arp for usb0"
        exit 1
    fi
 
    # set up proxy_arp for eth0, so this better be our
    # internet connection
    echo "1" >/proc/sys/net/ipv4/conf/eth0/proxy_arp

    # turn on IP forwarding
    echo "1" >/proc/sys/net/ipv4/ip_forward

    # delete the unwanted route via usb0
    # its wrong anyway
    /sbin/route del -net $IPAQ_NET dev usb0

    # add the route we really want
    /sbin/route add $IPAQ_ADDR dev usb0
}

stop() {
    /sbin/ifconfig usb0 down
    # rmmod -r usbnet
}
case "$1" in
    start|add)
        start
        ;;
    stop|remove)
        stop
        ;;
    *)
        echo $"Usage: $0 {start|stop|add|remove}"
        exit 1
esac

Once both ends are powered up and their respective usbX interfaces exist, the script will bring up PPP over USB.

You need to change the IP addresses in the script to be two unused IPs in your laptops wlan0 range
Code:
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255

You need to build the usbnet module for your laptop too, or change the script to use ethX at each end.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum