[Howto] Share Ethernet via Wifi with NetworkManager in KDE

KDE logoI recently was taking part in a training at a place which had poor cellular reception, no wifi and only one single ethernet connection. Thus we had to the ethernet via wifi. I tried to do just that with my laptop via NetworkManager – and it worked out of the box.

The basic situation is rather common: you have one single network connection, and want to share it to other people or devices via wifi. If you want to do that manually you have to set up the wifi network on your own, including encryption, need to bring up a dhcp server, configure the routing and NATing, and so on. That can take quite some time, and is nothing you want to do during some precious training hours.

Thus I simply tried to bring up a shared wifi via the NetworkManager applet in KDE:
Share-Wireless
After providing a SSID name and configuring some security credentials the process was already done, and I was notified that the network was set up and ready. It was also shown in the plasma applet besides the ethernet connection:
Plasma-Connection-Established
Plasma-Applet-Conncetions

And that was it already: everyone was able to connect to the network without any problems – and it didn’t even took me a minute to bring it all up. Since I know how much trouble it can be to bring such a connection up manually I was really impressed!

In case you want to give it a try, make sure that your wifi hardware and thus the appropriate driver; do support Access Point (AP) mode which is needed to bring up the wifi. If it says “for some devices only” you have no choice but give it a try.

By the way, in case you wonder about DNS and DHCP: both is done via dnsmasq as a local server, offering both. The DNS queries are forwarded to the DNS servers you got via DHCP from the ethernet connection (or, presumably the one you configured in NetworkManager).
However, I was not able to find any temporary configuration in /run or /var/ which showed the actual DNS servers – I had to call nm-tool to figure that one out:

$ nm-tool
- Device: eth0  [Standard-Ethernet] --------------------------------------------
[...]

  IPv4 Settings:
    Address:         192.168.3.27
    Prefix:          24 (255.255.255.0)
    Gateway:         192.168.3.1

    DNS:             192.168.2.4
    DNS:             192.168.2.3

If you know of any other way to find out these information, or even better simply the entire configuration of dnsmasq for that purpose please let me know =)

Besides, while the Plasma applet gave me the option to shut down the shared wifi network, I wasn’t able to bring it up again. There simply is no option in the network overview to fire up again such a network, thus I filled a bug report.

But, besides these two smaller issues, the plasma-nm applet and thus NetworkManager did a great job making sharing networks very easy.

About these ads

10 thoughts on “[Howto] Share Ethernet via Wifi with NetworkManager in KDE

  1. dnsmasq should use /etc/resolv.conf for upstream DNS server configuration by default and NetworkManager should write those there after a successfull connection

  2. Ah, I checked on a kubuntu system I have and it seems to be the case ;(. Looking at how dnsmasq is run:

    yoyo@yoyo:~$ ps uax | grep dnsmasq
    … /usr/sbin/dnsmasq –no-resolv –conf-file=/var/run/NetworkManager/dnsmasq.conf –enable-dbus=org.freedesktop.NetworkManager.dnsmasq –conf-dir=/etc/NetworkManager/dnsmasq.d ….

    there’s nothing in /etc/NetworkManager/dnsmasq.d and /var/run/NetworkManager/dnsmasq.conf is empty, so I guess networkmanager talks directly to dnsmasq through the dbus interface and there really might not be a way to find out the dns servers other then quering NetworkManager or dnsmasq directly

    1. yes, there is a similar shared option for wired and although I never tried it, it should actually be easier (no wifi/AP setup etc)

    2. Hej, like Yoyo wrote, that shouldn’t be a problem since the wifi driver just needs a normal connection. I haven’t tested it yet, though.

  3. liquidat: with the default kubuntu configuration, the dnsmasq dbus service is accessible only from root and has only some setter methods and some (dhcp) lease oriented signals, so I guess it is mostly intended just for internal NetworkManager dnsmasq communication.

    You should be able to query NetworkManager for that information (which is the authoritative source for the info :), but I never looked into it’s dbus interface… Unless you need to use it in another program, I guess that nm-tool would be the right user tool to get it…

  4. Just wanted to chime in and say thank you very much for this article.

    And not only can you share your wired connection but apparently any connection.

    In my case I’m using a 3G modem, sharing the connection via wifi to my phone, console and tablet and it works like a charm!

    So happy! :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s