Change log
1. Guide created. 03/10/10
2. Changed the rc.local config so that the computer won't hang on start up if your router is down. Also added the change log and test subjects. 03/10/10
3. Added support for WPA. 03/12/10
4. Added command under Preparation to find available (wireless) interfaces. 03/14/10
Tested on
Ubuntu 9.10
Linux Mint 8
using WEP 128-bit hex keys and WPA(TKIP)
--------------------------------------------------------------------------------Wireless Static IP Setup Guide-------------------------------------------------------------------------------------------
Hello all, my name is Clinton. Today I want to show you how to make a "static ip" for your wireless connection(without using DHCP) so you can use your computer as a server or to host games, etc. behind a router.
-------------------------------------------------------------------------------------Who Is This Guide For?-----------------------------------------------------------------------------------------------
For people who were not able to get satisfactory performance and results from the standard network managers. You should already have a working device and the correct drivers installed for your wireless device before using this guide. This guide will show you how to set up your wireless device at the lowest level, which means we won't be using any fancy GUI's such as the default network-manager, if you aren't comfortable with using the terminal or editing system files then perhaps this isn't the guide for you. The guide will also make your device connect automatically at start up without any user interaction. This guide is probably not ideal if you are using different routers all the time, such as if you are a using a laptop, taking it to work using the internet and then coming home to use the internet.
----------------------------------------------------------------------------------Why Am I Making This Guide?------------------------------------------------------------------------------------------
Simply because none of the other guides I could find worked for me or were only for wired connections. Two guides however strongly influenced me and taught me how to think correctly about how my computer runs and connects to the internet at start up. One was the Arch Linux Beginners guide and the other by a guy named Vivek Gite here.
----------------------------------------------------------------------------------------------Preparation------------------------------------------------------------------------------------------------------
BACKUP - seriously there is a chance that something could go wrong if you mess up the commands or for some strange reason this guide doesn't work and you are stuck with no internet. It happened to me several times where I would read a guide and then they told me to uninstall network manager(because it interferes with doing static ip and other stuff) and then I was stuck without internet. So be prepared there is a chance that this may not work. Use the guide at your own risk and then blame me for it not working, lol.
KNOWLEDGE OF NETWORK SETTINGS - this is crucial! If you don't know what an IP is used for or don't know what your DNS servers are then do not proceed! You must do your homework and figure out the following:
- What 'IP Address' do you want to use on the network? For instance my router will allow me to use any address starting at 192.168.1.100 to 149 so long as it isn't being used by another computer on the network. So if my laptop is using a DHCP IP 192.168.1.105 then that one is taken, I have to either manually delete that one from the router(or let it expire) first or pick another. By the way DHCP means the router is managing the IPs given to the local computers, using a Static IP(locally speaking) means we are just going to take the IP from the router ourselves. So another good idea (if you want to have your router use DHCP for some computers and then you manage the static ones for your servers) is to start the Static IP's at the top of the range since typically the router will hand out(DHCP) IP's in numerical order starting at 192.168.1.100 or whatever the range may be for your routers settings(you need to figure this out yourself so read up on your specific router if you don't know about your settings, I am using a Linksys). So if you chose a static IP of 192.168.1.100 and then someone else hopped on the network using regular DHCP settings then the router might take away your IP and give it to them. So just a good idea to start at the top of the range(149) for static IP's unless you are going to make every computer on the network use static. At least that is my experience.
- What is your Subnet Mask number? Again check your router settings. My router's default is 255.255.255.0 . My outside world Subnet Mask is different though(255.255.255.240) so make sure you know the one that your router is using for managing internal IP addresses.
- What are your DNS Server numbers? Generally speaking there is usually two of these. Know what they are. Again check your router's status or with your ISP if you aren't sure.
- What is your ISP's domain and search names? Mine are the same - satx.rr.com . These names are sometimes not required or needed.
- What interface do you need to use to control your wireless card? Use to see a list of available wireless devices(wlan0, ath0, etc.).
- What is your Broadcast number? Mine is 192.168.1.255 or so I've been told. I've also been told that you just replace the last number of your IP address with the biggest number of your Subnet Mask but I'm not sure. I recently found out from a more credible source that this number is your router number but the last number represents the maximum computers the router will handle hence the 255 the end. Figure yours out or just use the one you currently have before changing to static IP - find it by using Note: replace wlan0 with whatever interface you are using to connect to the internet. Some people use ath0, eth0, etc. Know your interface, make sure you have the proper drivers installed before continuing.
- What wireless security are you using? Unsecured, WEP, WPA, or WPA2? Know what you are using and know the pass codes for it. *****UNFORTUNATELY***** I haven't been able to make a guide for WPA2 *YET* because I haven't tried and tested it. However for WPA2 users this guide may still be very helpful at getting you started. You just need to do something extra with the wpa_passphrase command which I cannot offer support for since I don't use WPA2.
SAVE A COPY OF THIS GUIDE BEFORE PROCEEDING!
ALSO DO NOT PROCEED IF YOU HAVEN'T READ THE PREVIOUS SECTION 'PREPARATION'!
TURN OFF TEXT WRAPPING IN GEDIT BEFORE PROCEEDING MENU>ACCESSORIES>GEDIT>EDIT>PREFERENCES>UNCHECK TEXT WRAPPING THEN CLOSE IT
WARNING! I DON'T HAVE A GUIDE FOR WPA/WPA2 YET SO DON'T USE THE GUIDE UNTIL THEN USE ONLY FOR WEP AND UNSECURED
-------------------------------------------------------------------------------------------Get Down To Business------------------------------------------------------------------------------------------
1. Open a terminal. Remove the default network-manager.
Code:
sudo aptitude remove network-manager-gnome
Also you might want to remove other network managers you may have installed yourself(wicd, knetwork-manager, etc.) as these may conflict with the following setup.
2. Modify your /etc/network/interfaces file.
Code:
gksu gedit /etc/network/interfaces
This is a sample of mine. Copy the second part as you see fit.
auto lo
iface lo inet loopback
iface
wlan0 inet static
address
192.168.1.105
netmask
255.255.255.0
network
192.168.1.0
broadcast
192.168.1.255
gateway
192.168.1.1
dns-nameservers
24.93.41.127 24.93.41.128
dns-search
satx.rr.com
Replace the entries in red so that they correspond with your setup. Read the following for more info on each part.
wlan0 is the interface device that controls your wireless card, some computers use ath0 if they have an Atheros chip.
address is the IP address you want.
netmask is your Subnet Mask.
network is your Gateway BUT change the last number part to zero.
broadcast is your Broadcast number. Your IP number mixed with your Subnet Mask.
gateway is your Gateway or router address. Once we are connected to the internet you can type this number into a internet browser address bar to modify router settings.
dns-nameservers add your DNS servers to this line. Separate using a space.
dns-search this is your ISP search domain, add this if you have it otherwise don't add this entry.
3. Modify your /etc/hosts file. This file will create network aliases for your computer. So that when you type your hostname or IP in a browser it will know what computer to go to.
Code:
gksu gedit /etc/hosts
This is a sample of mine. You should only have to add a third line for your new alias so don't copy mine or delete lines from yours. Just add the IP you want and then copy your computer's name which should be on the second line already.
127.0.0.1 localhost
127.0.1.1 clinton-desktop
192.168.1.105 clinton-desktop
The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
4. Modify your /etc/resolv.conf file. This file stores your DNS servers and your ISP's search and domain names.
Code:
gksu gedit /etc/resolv.conf
This is a sample of mine. Replace the red entries as you see fit, nameserver = DNS server. Some people don't need a search or domain entry. Also you can delete the "Generated by network manager" comment if you have one.
search
satx.rr.com
domain
satx.rr.com
nameserver
24.93.41.128
nameserver
24.93.41.127
5. Save a copy of this guide to disk or print it out before running the next command! Restart the computer and then we will test the connection.
Once you are back up and running we will bring the interface up. Replace wlan0 with your interface if you need to.
Code:
sudo ifconfig wlan0 up
Now we will scan for your router.
Code:
sudo iwlist wlan0 scan
Now remember and perhaps write down the ESSID and Address(the long MAC address(i.e. 00:00:00:00:00:00) of the router you want to connect to. ESSID is also known as the name of the network.
Now we will try connecting to the network using either WPA, WEP or Unsecure. Must use quotes around ESSID's.
Replace the following ESSID's and MAC Addresses with your router's from the previous iwlist command.Unsecure Connection
Code:
sudo iwconfig wlan0 essid "youressidhereinquotes"
Code:
sudo iwconfig wlan0 ap 00:00:00:00:00:00
Again don't forget to change the ESSID, MAC Address and WEP hex key. WEP Connection
Code:
sudo iwconfig wlan0 essid "youressidhereinquotes" key whateveryourhexkeyishere
Code:
sudo iwconfig wlan0 ap 00:00:00:00:00:00
WPA Connection
For WPA connections we have to use an additional tool kit called wpa_supplicant. First off we make a config file for it.
Code:
sudo touch /etc/wpa_supplicant.conf
Next we change the ownership of it so we can modify it.
Change "yourusername" to your computer user name.
Code:
sudo chown yourusername /root /etc/wpa_supplicant.conf
Now we will set your WPA password, change it to hex so the router can read it and then automatically place the info into the wpa_supplicant.conf we made previously.
Again replace the ESSID with your own, also change the password to the one you setup in the router for WPA.
Code:
sudo wpa_passphrase youressid "yourwpapassword" > /etc/wpa_supplicant.conf
Now since your WPA password will be stored in plain text we should make it only readable by the root user.
Code:
sudo chmod 0600 /etc/wpa_supplicant.conf
Now we will try to associate our wireless device with the router.
Replace the essid in "quotes" with your own.
Code:
sudo iwconfig essid "youressidhere"
Now we will set up a secure WPA connection.
Replace wlan0 with your own interface if you need to.
Code:
sudo wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf
Now wait about 5-10 seconds to let it authenticate and then continue with the guide.
Okay we are almost connected now. Now we will assign the IP using ifconfig.
Replace the interface and IP with the one you need.
Code:
sudo ifconfig wlan0 192.168.1.105
Now test your connection by going to google.com in a browser. If everything works then skip to step # 6, if something fails later come back and try this step though.
Okay for those of you who couldn't access the internet yet we just need to do one more step. We will manually add our router/gateway to the routing table.
Replace the gateway(router) address with your own.
Code:
sudo route add default gw 192.168.1.1
Alright you should be able to use the internet now - Proceed to step 6.
If you can't connect then retrace your steps and make sure you didn't type anything wrong, it's very easy to make a typo! If you are trying to connect using WPA you may want to restart and then try connecting again or just continue with the guide since the computer may need to reload the .conf file we made. If you failed using WEP double check that you entered your hex key correctly they can be tricky to the eyes at times. Post if you have problems, I'll try my best to help, use pastebay.org or pastebin.com to copy your debug info into and then post the links and your situation.
6. Okay now the last step - we will set up your computer so it automatically connects to the network every time your computer starts. To do this we will modify the /etc/rc.local file.
Code:
gksu gedit /etc/rc.local
Here I've included two different set ups, one for WEP/Unsecure and one for WPA.
WARNING: DO NOT LEAVE OUT THE "exit 0" LINE; Also do not foget the semi colons, backward slashes (\'s) and ampersand(&) for the last command.
FOR WEP/UNSECURE CONNECTIONS
This is a sample of mine.
Replace the red entries as you see fit.I am set up for using WEP, so if you are using Unsecured just remove part of the line starting with the word "key".
The second 'ifconfig' command will set your IP so don't forget to use the one you desire. The route command will add your gateway/router to the routing table.
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
ifconfig
wlan0 up ; \
iwconfig
wlan0 essid "
yourESSIDhere" key
yourhexkeyhere ; \
iwconfig
wlan0 ap
00:00:00:00:00:00 ; \
ifconfig
wlan0 192.168.1.105 ; \
route add default gw
192.168.1.1 &
exit 0
FOR WPA CONNECTION
This is a sample of mine for WPA.
Replace the red entries as you see fit. The route command will add your gateway/router to the routing table. The second 'ifconfig' command will set your IP so don't forget to use the one you desire. If you have a really slow or prehistoric computer you may want to increase the value of the second sleep command to 10 (seconds).
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
ifconfig
wlan0 up ; \
iwconfig
wlan0 essid "
youressid" ; \
sleep 5; \
wpa_supplicant -B -Dwext -i
wlan0 -c /etc/wpa_supplicant.conf ; \
sleep 5; \
ifconfig
wlan0 192.168.1.105 ; \
route add default gw
192.168.1.1 &
exit 0
WARNING: DO NOT LEAVE OUT THE "exit 0" LINE; Also do not foget the semi colons, backward slashes (\'s) and ampersand(&) for the last command.
Alright you should be done now and whenever your computer starts it will automatically connect to your network. I hope you enjoyed the guide. Let me know if it helped or not.
Peace to the world.
Bookmarks