3

I have a macbook with ubuntu quantal running on it and I also have a device with a linux distro (FYI, a raspberry pi*).

I've been trying to set up the device to share my laptop's wireless connection through the ethernet port. The problem is that I do not want to allow the ip address of the device to change (so I guess I don't want to use DHCP), since it has no interface other than the ssh connection that I open from my ubuntu laptop.

Thus, the question is: how can I set up both ubuntu and the device to have it using ubuntu's wireless connection through the ethernet cable, but without ever changing the ip address of the eth0 port in the device? I do not want to change it because I'd like to always be able to find it on the network without having to edit its filesystem in another machine...

* I think this problem is more related to ubuntu than to the raspberry pi, so I believe this is the right forum to ask this question.

Seth
  • 59,332

2 Answers2

1

I've managed so far, but I don't know if that's the ideal solution. Anyhow, it might be useful enough for someone else:

I created a wired internet-share connection (click on the network icon on the top left corner of the screen -> edit connections... -> Wired tab -> Add -> IPv4 settings -> Method -> Shared to other computers; also made sure that the box "Available to all users" in the same window was checked). Once I connected to this connection, I checked my ipaddress (10.42.0.1) and netmask (255.255.255.0) with ifconfig. Finally, I set the static ip address of the raspberry pi to be the one I had with the shared connection +1 (= 10.42.0.2) and set the gateway to the address of the laptop (10.42.0.1), ending up with the following contents in the /etc/network/interfaces on the raspberry pi:

auto lo

iface lo inet loopback

#iface eth0 inet dhcp

iface eth0 inet static
address 10.42.0.2
netmask 255.255.255.0
gateway 10.42.0.1

So far, this is working.

0

This is a pretty old question, but I've just faced the same challenge when sharing my laptop's WiFi internet connection via Ethernet.

My solution consists of the following steps:

  • Share internet connection on Ethernet using the Shared to other computers option in the network manager (how-to).
  • Find out more details about a DHCP server Ubuntu uses for serving shared connection to clients:
    ps aux | grep dhcp
    /usr/sbin/dnsmasq --conf-file=/dev/null --no-hosts --keep-in-foreground --bind-interfaces --except-interface=lo --clear-on-reload --strict-order --listen-address=10.42.0.1 --dhcp-range=10.42.0.10,10.42.0.254,60m --dhcp-lease-max=50 --dhcp-leasefile=/var/lib/NetworkManager/dnsmasq-enx3c18a00ad953.leases --pid-file=/run/nm-dnsmasq-enx3c18a00ad953.pid --conf-dir=/etc/NetworkManager/dnsmasq-shared.d
    
  • The output indicates that:
    • Ubuntu uses dnsmasq daemon as the DHCP server,
    • the location where dnsmasq looks for the config is /etc/NetworkManager/dnsmasq-shared.d.
  • Put a config file (the name actually doesn't matter) to that folder and add the following entry (man-page):
    # dhcp-host=CLIENT_MAC,CLIENT_IP
    dhcp-host=de:ad:be:ef:fe:ed,10.42.0.2
    
  • Unplug your Ethernet cable and plug it in again so your client gets a new DHCP lease; it should get 10.42.0.2/24 IP.
pernik
  • 1