Fedora – Setting up an ad-hoc network on boot

bootfedoranetworkingwifi

I'm pretty new to Linux; this project is me trying to learn more. I've done login scripts before but not boot scripts, so that's one of my questions. My other question is how to get an ad-hoc network working with just terminal commands, so that I can make a boot script to do it. I'm running Fedora 18 off of a flash drive for now, but when I'm done configuring I'll be copying everything to an old laptop's hard drive. (The goal of this project is to not have to buy a better wireless router)

The most luck I've had setting up an ad-hoc was by using Gnome's "Use as Hotspot…" button in my wireless network settings, and then changing the name and WEP code (Can I use other encryption methods?) using iwconfig in the terminal, but I want it all done with terminal commands so that I can just run a script to set it all up. I think I can figure out how to use iptables to set up my port forwarding and junk myself, but first I need to get this computer able to share its internet connection wirelessly.

Best Answer

This blogspot entry has a guide for configuring a wireless network in ad-hoc mode. On the first machine, run these commands (fill in your own network information):

 ifconfig wlan0 down
 iwconfig wlan0 channel 4
 iwconfig wlan0 mode ad-hoc
 iwconfig wlan0 essid 'fermilevel'
 iwconfig wlan0 key 1234567890
 ifconfig wlan0 192.168.1.1

On the second machine:

 ifconfig wlan0 down
 iwconfig  wlan0 channel 4
 iwconfig  wlan0 mode ad-hoc
 iwconfig  wlan0 essid 'fermilevel'
 iwconfig  wlan0 key 1234567890
 ifconfig  wlan0 192.168.1.2

The essid and key must be the same on both machines.

Related Question