7 Replies - 301 Views - Last Post: 08 November 2017 - 09:22 PM

#1 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1523
  • View blog
  • Posts: 8,301
  • Joined: 07-September 06

NetworkManager ad-hoc wireless networking

Posted 07 November 2017 - 09:48 AM

I always feel like these things should be easy, and then they aren't. But what I am attempting to do is set up an ad-hoc wireless network via NetworkManager (not a strict requirement, but it is nice to not have to install a bunch of extra stuff... and the arch-wiki's ad-hoc page (which did require extra stuff) didn't seem to work).

So, here is my setup:
1 Linux box (running Fedora 26) with a 1GB ethernet port (plugged in) and a USB wifi dongle (Edimax EW-7811Un to be specific).

I want to get the wifi dongle set up as an ad-hoc network (along with dhcp, though only on that interface).

What I have done so far (all values in <...> are things that I specified):

Quote

nmcli connection add type wifi ifname <wlp1s0f0u5> con-name <adhocNetwork1> autoconnect yes ssid <LyssaNet> mode <adhoc>
nmcli connection modify <adhocNetwork1> 802-11-wireless.mode <adhoc> 802-11-wireless-security.key-mgmt <wpa-psk> ipv4.method <link-local> 802-11-wireless-security.psk <"PASSWORD">
nmcli connection up <adhocNetwork1>


Now, that seemed to work... with the exception that another machine I tried to connect to wasn't getting an IP address. This isn't a huge thing as I hadn't set up dnsmasq at that point.

I went through an modified the dnsmasq file to have it run a dhcp server and hand out IPs in a relatively large range. Here's a copy of that:
/etc/dnsmasq.conf
dhcp-range=169.254.1.1,169.254.254.254
no-dhcp-interface=enp8s0


# Include all files in /etc/dnsmasq.d except RPM backup files
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig



And just to make sure I am being thorough, here is /etc/sysconfig/network-scripts/ifcfg-adhocNetwork1:
ESSID=LyssaNet
MODE=Ad-Hoc
MAC_ADDRESS_RANDOMIZATION=default
TYPE=Wireless
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=autoip
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=adhocNetwork1
UUID=a995b88b-d246-4127-b8bd-5d167aa6078e
DEVICE=wlp1s0f0u5
ONBOOT=yes
KEY_MGMT=WPA-PSK
WPA_ALLOW_WPA=yes



Basically, there the biggest thing was that I don't want to conflict with the in-house router and modem that is already handing out dhcp addresses (as such, I tell it to ignore the wired interface).

When I attempted to start dnsmasq I got errors saying that the dhcp port was already bound by another application. After looking around a bit I found that NetworkManager starts a dnsmasq instance to allow file sharing. Great, find, whatever. I figure that the best way to go about getting it all reloaded and in a good state is to reboot (when in doubt and all that).

After rebooting I am now running in to an issue where I can't get the adhoc network up anymore.

Quote

[email protected] ~ ▶▶sudo nmcli connection up adhocNetwork1
Error: Connection activation failed: No suitable device found for this connection.
[email protected] ~ ▶▶sudo nmcli connection show
NAME UUID TYPE DEVICE
enp8s0 5538d7e4-3eeb-3167-a266-bc0f282495b5 802-3-ethernet enp8s0
virbr0 a15e9dde-da8c-4b41-8b5d-054777320bf8 bridge virbr0
vnet0 86a08b2f-5484-4a9a-b5e7-77d5482b2e19 tun vnet0
adhocNetwork1 a995b88b-d246-4127-b8bd-5d167aa6078e 802-11-wireless --
[email protected] ~ ▶▶



So, for whatever reason it appears that the association between my adhoc network and my wireless device has been lost.

Quote

[email protected] ~ ▶▶ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 30:9c:23:28:64:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.53/24 brd 192.168.0.255 scope global dynamic enp8s0
valid_lft 84046sec preferred_lft 84046sec
inet6 2601:280:4800:470:582c:30f4:801b:6063/64 scope global noprefixroute dynamic
valid_lft 345592sec preferred_lft 345592sec
inet6 fe80::111b:46e3:7670:e930/64 scope link
valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:c1:4b:e2 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:c1:4b:e2 brd ff:ff:ff:ff:ff:ff
5: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN group default qlen 1000
link/ether fe:54:00:40:a6:56 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fe40:a656/64 scope link
valid_lft forever preferred_lft forever
6: wlp1s0f0u5: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether ba:d3:5c:cb:ff:61 brd ff:ff:ff:ff:ff:ff

[email protected] ~ ▶▶sudo nmcli connection show adhocNetwork1
connection.id: adhocNetwork1
connection.uuid: a995b88b-d246-4127-b8bd-5d167aa6078e
connection.stable-id: --
connection.interface-name: wlp1s0f0u5
connection.type: 802-11-wireless
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.autoconnect-retries: -1 (default)
connection.timestamp: 1510069529
connection.read-only: no
connection.permissions: --
connection.zone: --
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: -1 (default)
connection.secondaries: --
connection.gateway-ping-timeout: 0
connection.metered: unknown
connection.lldp: -1 (default)
802-11-wireless.ssid: LyssaNet
802-11-wireless.mode: adhoc
802-11-wireless.band: --
802-11-wireless.channel: 0
802-11-wireless.bssid: --
802-11-wireless.rate: 0
802-11-wireless.tx-power: 0
802-11-wireless.mac-address: --
802-11-wireless.cloned-mac-address: --
802-11-wireless.generate-mac-address-mask:--
802-11-wireless.mac-address-blacklist: --
802-11-wireless.mac-address-randomization:default
802-11-wireless.mtu: auto
802-11-wireless.seen-bssids: --
802-11-wireless.hidden: no
802-11-wireless.powersave: default (0)
802-11-wireless-security.key-mgmt: wpa-none
802-11-wireless-security.wep-tx-keyidx: 0
802-11-wireless-security.auth-alg: --
802-11-wireless-security.proto: wpa
802-11-wireless-security.pairwise: --
802-11-wireless-security.group: --
802-11-wireless-security.leap-username: --
802-11-wireless-security.wep-key0: <hidden>
802-11-wireless-security.wep-key1: <hidden>
802-11-wireless-security.wep-key2: <hidden>
802-11-wireless-security.wep-key3: <hidden>
802-11-wireless-security.wep-key-flags: 0 (none)
802-11-wireless-security.wep-key-type: 0 (unknown)
802-11-wireless-security.psk: <hidden>
802-11-wireless-security.psk-flags: 0 (none)
802-11-wireless-security.leap-password: <hidden>
802-11-wireless-security.leap-password-flags:0 (none)
ipv4.method: link-local
ipv4.dns: --
ipv4.dns-search: --
ipv4.dns-options: (default)
ipv4.dns-priority: 0
ipv4.addresses: --
ipv4.gateway: --
ipv4.routes: --
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-timeout: 0
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.dhcp-fqdn: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv4.dad-timeout: -1 (default)
ipv6.method: auto
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: (default)
ipv6.dns-priority: 0
ipv6.addresses: --
ipv6.gateway: --
ipv6.routes: --
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.addr-gen-mode: stable-privacy
ipv6.dhcp-send-hostname: yes
ipv6.dhcp-hostname: --
ipv6.token: --
proxy.method: none
proxy.browser-only: no
proxy.pac-url: --
proxy.pac-script: --


I have also ensured that my wifi is turned on (and the physical hardware concurs with the power LED showing).
sudo nmcli radio wifi on

I have also "up"ed the wireless interface.

So, I feel like I am missing something really basic as far as how to get the wireless device re-associated with the connection so I can fire the ad-hoc network back up and see if I have IPs properly handed out this time, but I haven't been able to find anything of use at this point. Any Linux networking gurus out there have a clue what I am missing?

Thanks for your time!

Is This A Good Question/Topic? 0
  • +

Replies To: NetworkManager ad-hoc wireless networking

#2 jimblumberg   User is offline

  • member icon

Reputation: 5537
  • View blog
  • Posts: 17,144
  • Joined: 25-December 09

Re: NetworkManager ad-hoc wireless networking

Posted 07 November 2017 - 11:13 AM

What does the ifconfig report about your interfaces?

How is your wifi dongle getting it's IP address and netmask (DHCP/Manual/?)?




Jim
Was This Post Helpful? 0
  • +
  • -

#3 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1523
  • View blog
  • Posts: 8,301
  • Joined: 07-September 06

Re: NetworkManager ad-hoc wireless networking

Posted 07 November 2017 - 11:31 AM

Here's the output of ifconfig (currently - I have been playing with it and it looks like ad-hoc networks aren't very supported in NetworkManager, but if I change it to a access point (ap) I can get it going).

Quote

[email protected] ~ ▶▶ifconfig
enp8s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.53 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 2601:280:4800:470:582c:30f4:801b:6063 prefixlen 64 scopeid 0x0<global>
inet6 fe80::111b:46e3:7670:e930 prefixlen 64 scopeid 0x20<link>
ether 30:9c:23:28:64:00 txqueuelen 1000 (Ethernet)
RX packets 135166 bytes 106958616 (102.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 94048 bytes 16251398 (15.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xef200000-ef21ffff

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 1000 (Local Loopback)
RX packets 36309 bytes 12610755 (12.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 36309 bytes 12610755 (12.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:c1:4b:e2 txqueuelen 1000 (Ethernet)
RX packets 43326 bytes 14252042 (13.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 45738 bytes 23811127 (22.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::fc54:ff:fe40:a656 prefixlen 64 scopeid 0x20<link>
ether fe:54:00:40:a6:56 txqueuelen 1000 (Ethernet)
RX packets 43326 bytes 14858606 (14.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 50229 bytes 24060313 (22.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlp1s0f0u5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.32.126 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::82d1:a4c6:d472:6210 prefixlen 64 scopeid 0x20<link>
ether 74:da:38:2a:e9:4a txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 320 bytes 45675 (44.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


At this point dnsmasq is handing out the IP address and the netmask to the wireless dongle, though it appears to also be having issues in that I can't seem to connect other machines to the network (the "LyssaNet" wifi network shows up on them, and I can input the credentials, but it seems to time out - I am guessing on getting assigned an IP address, but am uncertain there).

This (using the wireless dongle as an access point instead of ad-hoc network) seems to be working better than previously, but still not as much as I would like.

One thing to note is that I am attempting to limit the connectivity of anything on that network to "link-local" which based on reading should only allow access to machines on the same network, so that may be part of the problem at the moment... I am uncertain.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg   User is offline

  • member icon

Reputation: 5537
  • View blog
  • Posts: 17,144
  • Joined: 25-December 09

Re: NetworkManager ad-hoc wireless networking

Posted 07 November 2017 - 12:02 PM

Is this Linux box trying to connect to an existing ADHOC network or are you trying to completely setup a "new" ADHOC network?

Have you tried using a manual IP/Netmask as a start? Once you get the manual connection working it should be easy to switch over to DHCP.



Jim
Was This Post Helpful? 0
  • +
  • -

#5 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1523
  • View blog
  • Posts: 8,301
  • Joined: 07-September 06

Re: NetworkManager ad-hoc wireless networking

Posted 07 November 2017 - 12:12 PM

So, this is a Linux box trying to create a completely new ad-hoc network.

My primary test for it is to get a phone (Android) to connect to said ad-hoc network once it is set up and be properly given an IP address (ideally via dhcp so I don't have to set static IPs for everything, since it could be conceivable that a new device would want to connect to said network and I don't want to have to do more than provide the login credentials).

I haven't, at this point, attempted to assign manual IPs to the connecting devices. I'd actually have to look up how to do that in Windows (what I am using to attempt a test client with, so it at least as a bit more functionality and ease-of-use than a phone).
Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg   User is offline

  • member icon

Reputation: 5537
  • View blog
  • Posts: 17,144
  • Joined: 25-December 09

Re: NetworkManager ad-hoc wireless networking

Posted 07 November 2017 - 01:25 PM

Okay, I did a quick setup using information on this page using two Linux systems. This is using manual IP addresses to make things simpler. Once I turned off my firewalls on both systems I was able to ping the other computer.

As I said this is just a quick check to see if the Ad-hoc network was working, I used IP addresses of 192.168.15.10 and 192.168.15.50 and 192.168.15.100 all with netmasks of 255.255.255.0. The next step would be to add DHCP to allow the "remote" systems to get their IP addresses automatically. To make things easier don't use DHCP on the computer running the DHCP server until you insure the "remote" computers can connect and receive their IP addresses correctly.


By the way I happen to be using Mageia Linux on both machines.


Jim
Was This Post Helpful? 1
  • +
  • -

#7 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1523
  • View blog
  • Posts: 8,301
  • Joined: 07-September 06

Re: NetworkManager ad-hoc wireless networking

Posted 08 November 2017 - 01:32 PM

Victory!

Okay, so I followed the instructions that you linked above, it turns out that Android doesn't (at least as far as I can tell) support ad-hoc networks, and as a result it didn't work with the systems I had available at the time to test.

I then went through and set up a "hotspot" instead of the ad-hoc network that I was going for (since the hotspots seemed to work) and looked at the differences in the settings between what I was setting up and what the hotspot set up. It wasn't much different, so I set the few settings that the hotspot configured and I hadn't been:

802-11-wireless.mode:                   ap
// and
802-11-wireless.mac-address:            <WIFI_MAC_ADDRESS_HERE>
// and
802-11-wireless-security.proto:         rsn
802-11-wireless-security.pairwise:      ccmp
802-11-wireless-security.group:         ccmp
// and
ipv4.method:                            manual
// and
ipv4.addresses:                         193.169.1.1/16 // NOTE: This is based on whatever you want it to be, but I set it to be the same range as what my dhcp server was set to hand out.



After restarting the service I was able to connect to the "ad-hoc" network (it is worth noting that it wasn't a literal ad-hoc network at this point, but instead an access point network that was segregated from the rest of the network and thus didn't have internet access). But, I was failing to be given out a DHCP IP address.

My dnsmasq config:
dhcp-range=193.169.1.1,193.169.254.254,255.255.0.0,1h
dhcp-host=<WIFI_MAC_ADDRESS_HERE>,193.169.1.1
no-dhcp-interface=eno1

# Include all files in /etc/dnsmasq.d except RPM backup files
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig



When attempting to start the dnsmasq service I would get an error saying that the ports were already bound. It isn't the most useful error since it was attempting multiple port bindings, but I was able to notice that _something_ was binding port 67 and 68 (dhcp server and dhcp client, respectively).

Running a netstat -teplun, I saw that both ports were in fact in use, and when I sudo'd the command I was able to get the PID. Using the pid in ps -<PID> didn't show anything, which was strange (even if you sudo'd the command). So I went to /proc/<PID>/ and was able to cat (as sudo) the cmdline file in the directory to see what was running in that process. It turns out that libvirt had started its own dhcp server.

After a bit of searching, I found how to disable that (link: https://docs.opensta...c-libvirt.html)
which basically came down to virsh net-autostart --network default --disable.

I then rebooted my machine, and when it came back I was able to get dnsmasq started appropriately.

However, I was still unable to obtain an IP from my phone when connecting to the network. I verified that dnsmasq was controlling the dhcp ports as it should be, and then it supposed it was likely a firewall problem:
sudo firewall-cmd --get-default-zone    // prints the default zone, copy this
sudo firewall-cmd --zone=<DEFAULT_ZONE> --add-service=dhcp
sudo firewall-cmd --zone=<DEFAULT_ZONE> --add-service=dns



It is worth noting that I didn't permanently add the services to the firewall, as I don't want them around all the time.

Finally, I was able to get assigned an IP address via DHCP on an "ad-hoc" network (like I said, it isn't an actual ad-hoc network, but it is doing what I want and is supported by the devices that I care about).

Small victories, but this has been a trying couple of days :)
Was This Post Helpful? 1
  • +
  • -

#8 jimblumberg   User is offline

  • member icon

Reputation: 5537
  • View blog
  • Posts: 17,144
  • Joined: 25-December 09

Re: NetworkManager ad-hoc wireless networking

Posted 08 November 2017 - 09:22 PM

Glad you got it sorted out.

As far as I can tell you are correct about the androids not being ad-hoc aware.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1