Linux – How to create an ad-hoc connection

arch linuxconnection-sharingnetworkingnetworkmanagerwifi

I need to make an adhoc connection on Archlinux (netbook used as a wifi repeater), I was using this tutorial to do it on Ubuntu :

At the terminal install execute sudo apt-get install dnsmasq-base and then sudo apt-get remove dnsmasq

Restart the NetworkManager by executing sudo /etc/init.d/network-manager restart

Left-click on the NetworkManager icon and click "Create New Wireless Network"

Name it "UbuntuAdhoc" and set the encryption to "WEP40"

Connect PC2 using Ad-Hoc to the PC1

The main problem is dnsmasq-mase is missing but dnsmasq is present on Archlinux.

Here's what I found that could be helpful:

https://wiki.archlinux.org/index.php/Dnsmasq
https://bbs.archlinux.org/viewtopic.php?id=6431

pacman -S dnsmasq
mkdir /etc/dnsmasq
mv /etc/resolv.conf /etc/dnsmasq
cd /etc
echo nameserver 127.0.0.1 > resolv.conf
mv rc.conf rc.conf.save 
sed  '/DAEMON/s/network/network dnsmasq.local/g' rc.conf.save>rc.conf
cd rc.d
sed  '/-z/s/dnsmasq/dnsmasq -r /etc/dnsmasq/resolv.conf /g' dnsmasq>dnsmasq.local
/etc/rc.d/dnsmasq.local start
/etc/rc.d/network restart

I have a problem with:

sed  '/-z/s/dnsmasq/dnsmasq -r /etc/dnsmasq/resolv.conf /g' dnsmasq>dnsmasq.local

It say that's the ../s/.. is not a known option.

It seems to have broken the networkmanager applet on xfce4. I blacklisted the dnsmasq stuff in /etc/rc.conf, it will be to repair in the progress, I can't use my wifi connection for now but my lan will do for now …

I also checked about various ways of using a adhoc connection, as my girlfriend use my PC and I travel sometimes, I need a graphical way to make the adhoc connection.

I checked my favorite software wicd but it cannot make multiple connections and adhoc. It said that the version 2.0 maybe would but for now, the only alternative is networkmanager.

So, how I do it?

Best Answer

The sed command is broken (I guess people overlooked it somehow on the forum you refer to). It should be:

sed  '/-z/s:dnsmasq:dnsmasq -r /etc/dnsmasq/resolv.conf :g' dnsmasq>dnsmasq.local

The fact that you used that broken sed command resulted in erasing /etc/rc.d/dnsmasq.local (or creating it as an empty file). I don't know the details of how NetworkManager is configured on Ubuntu, but I'm guessing that the fact of /etc/rc.d/dnsmasq.local being empty can have an important impact on your whole network configuration.

You can either:

  • Verify that /etc/rc.d/dnsmasq.local really is empty and if so, remove it - your network configuration should get back to the state at which it was before issuing that unfortunate sed command.

  • cd into `/etc/rc.d/ and run the corrected sed command above. This should create the dnsmasq.local file containing what the author of that forum post really intended. Possibly the rest might work after that.

Related Question