Share cable internet using wireless

Asked by Peter Garrone

I am attempting to connect to the net from my mobile phone, via a laptop running Ubuntu 10.04 LTS that is connected to cable ethernet. I cannot detect any wifi server from the mobile phone, though it detects several others.

From ubuntu, I created a new wireless connection in network manager (It provides a list of several available wifi servers, even though I have not requested this I believe). Wireless is enabled in network manager. When I edit the new wireless connection that I created, I see the following:
- The ssid is set to the name of the connection.
- it has an ad-hoc mode,
- "connect automatically" is not set. (when it was, the device registered xmit traffic according to ifconfig wlan0)
- I have pasted in the mac address of the device I am attempting to use, though not prompted to do so.
- there is no bssid field set.
- available to all users is set.
- mtu is set to automatic
- in ipv4 settings, the "shared to other computers" option is set. All other fields are blank.
- in wireless security, set "wep 128 bit passphrase" and a password.

From the command line, if I enter "$ sudo ifconfig wlan0" I get:
wlan0 Link encap:Ethernet HWaddr 00:1f:3a:f7:97:bf
          UP BROADCAST MULTICAST MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

And the command "$ iwconfig wlan0" gives:
wlan0 IEEE 802.11bg ESSID:off/any
          Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
          Retry long limit:7 RTS thr:off Fragment thr:off
          Power Management:off

Although I can use iwconfig to set the ESSID, I have never seen it set to the value that I have requested network manager to set it to. The service dnsmasq appears to be running. I am unsure if this is a result of my prior configuration attempts, or network manager has started it.

Although I have never used the wireless connection, the problem appears to be a software disconnect between network manager and the hardware. I have never managed to set the wireless device to ad-hoc mode if ifconfig says the connection is up. I would expect network manager to manage the device, set it to adhoc mode, and allow wifi connections. Yet this does not occur.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-nettool Edit question
Assignee:
No assignee Edit question
Solved by:
Peter Garrone
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

https://help.ubuntu.com/community/Internet/ConnectionSharing

I suggest you buy a router to share the connection (unless you leave your PC on 24/7) as the power use of a PC is a LOT higher than a home grade router.

Revision history for this message
Peter Garrone (pgarrone) said :
#2

Shouldn't network manager handle all this? There seem to be about 15 different CLI sudo commands as well as a couple of configuration files to set in the document you link to.

Your suggestion regarding buying a router is valuable.

Revision history for this message
Peter Garrone (pgarrone) said :
#3

My mistake the document does indeed describe connecting using network manager.

However it seems incorrect to me.

It seems to suggest that the WAN or internet connection be set to "shared to other computers" (although the document author notes his own confusion on the issue). This setting in fact means that the LAN connection is intended to be through that port, and that dhcp and dns/nat/masquerading will be done, that is the computer will be a router from other local computers connecting to that port to the internet through some other port that is not set to be "shared to other computers" but set to obtain ip address using dhcp.

Setting my main ethernet connection to "shared to other computers" definitely did not work.

For example this link here suggests this is indeed the case:

https://jeremy.visser.name/2009/03/24/simple-internet-connection-sharing-with-networkmanager/

However setting up with network manager as this document indicates does not work. The log files increase steadily. There appears to be an error which causes the whole procedure to fail as follows:

Sep 13 22:15:17 bacchus NetworkManager: <info> Starting dnsmasq...
Sep 13 22:15:17 bacchus NetworkManager: <debug> [1284380117.064635] nm_dnsmasq_manager_start(): Command line: /usr/sbin/dnsmasq --no-hosts --keep-in-foreground --bind-interfaces --except-interface=lo --clear-on-reload --strict-order --listen-address=10.42.43.1 --dhcp-range=10.42.43.10,10.42.43.100,60m --dhcp-option=option:router,10.42.43.1 --dhcp-lease-max=50 --pid-file=/var/run/nm-dnsmasq-wlan0.pid
Sep 13 22:15:17 bacchus NetworkManager: <debug> [1284380117.065767] nm_dnsmasq_manager_start(): dnsmasq started with pid 9061
Sep 13 22:15:17 bacchus NetworkManager: <info> (wlan0): device state change: 7 -> 8 (reason 0)
Sep 13 22:15:17 bacchus NetworkManager: <debug> [1284380117.066436] periodic_update(): Roamed from BSSID 00:00:00:00:00:00 (Bacchus) to (none) ((none))
Sep 13 22:15:17 bacchus NetworkManager: <info> Activation (wlan0) successful, device activated.
Sep 13 22:15:17 bacchus dnsmasq[9061]: failed to bind listening socket for 10.42.43.1: Address already in use
Sep 13 22:15:17 bacchus dnsmasq[9061]: FAILED to start up
Sep 13 22:15:17 bacchus NetworkManager: <info> Activation (wlan0) Stage 5 of 5 (IP Configure Commit) complete.
Sep 13 22:15:17 bacchus NetworkManager: dnsmasq exited with error: Network access problem (address in use; permissions; etc) (2)
Sep 13 22:15:17 bacchus NetworkManager: <info> (wlan0): device state change: 8 -> 9 (reason 18)
Sep 13 22:15:17 bacchus NetworkManager: nm_ap_get_ssid: assertion `NM_IS_AP (ap)' failed
Sep 13 22:15:17 bacchus NetworkManager: <info> Activation (wlan0) failed for access point ((none))
Sep 13 22:15:17 bacchus NetworkManager: <info> Activation (wlan0) failed.
Sep 13 22:15:17 bacchus NetworkManager: <info> (wlan0): device state change: 9 -> 3 (reason 0)
Sep 13 22:15:17 bacchus NetworkManager: <info> (wlan0): deactivating device (reason: 0).
Sep 13 22:15:17 bacchus avahi-daemon[982]: Withdrawing address record for 10.42.43.1 on wlan0.
Sep 13 22:15:17 bacchus avahi-daemon[982]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 10.42.43.1.
Sep 13 22:15:17 bacchus avahi-daemon[982]: Interface wlan0.IPv4 no longer relevant for mDNS.

I feel the failure to bind to the dnsmasq listening socket is significant. I think I will get the source for network manager, try the latest, and if there are still problems, head over to the network manager lists.

Revision history for this message
Peter Garrone (pgarrone) said :
#4

There was a conflict between dnsmasq and network manager. The documentation for this package (at https://help.ubuntu.com/community/Dnsmasq) suggests that it is incompatible with network-manager, and indeed it is, because the dnsmasq process that network manager launches to share connections attempts to open as server the same port that the dnsmasq package task opens. I probably installed dnsmasq because about a year ago I was connecting via firewire from another computer and configured it manually. I would suggest the use of the debian package "conflict" field to create a conflict between network manager and dnsmasq, although of course it is possible to use network manager to only manage the WAN port and configure the LAN port manually. Possibly when a user applies a configuration "shared to other computers" when editing a connection, some sort of check could be made for existing dnsmasq service, or indeed if the port (port 67 I believe) is in use, and give a warning about a conflict.

This problem appears to be the subject of discussion in bug #389006. (https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/389006)Mark Shuttleworth's post indicates that the problem is fixed if dnsmasq is killed. They seem to be suggesting that it is some sort of bug if two identical dnsmasq processes will not bind to the same port on the same computer; this seems normal behavior to me, but I am probably wrong.

The wireless port is not configured at boot though. It only configures if the network manager service is bounced. Although the wlan port is configured as ad-hoc and is up and it all looks good, my phone will not recognize it, which is probably a hardware problem. So problem is not yet solved.

Revision history for this message
Peter Garrone (pgarrone) said :
#5

And I have discovered that to use ad-hoc mode I would need to root my android phone. Or I could attempt to get hostapd running to operate the wireless port in master mode. So I am going to set this question as resolved. Thanks for anybody taking any interest.