Friday, September 23, 2011

Setting up wireless router in opensuse linux 11.4 box

I have a DELL inspiron Laptop with default Windows-Vista as OS. I installed OpenSUSE 11.4 on a different partition. It is easy to setup anything in Win-Vista. However its quite challenging to setup in Linux box. It is very interesting and helpful if you are learning linux.

I have broadband cable connection whose ethernet cable pin was broken. Even I wanted to browse from anywhere in house. So one of my friend suggested to buy a wireless router through which I can achieve flexibility in Internet browsing.

I bought a wireless router from ebay site costing around 1k. It arrived 2 days after the order was placed. Initially we need to connect the output of cable modem to the Internet port of Wireless router. We can connect upto 4 ethernet cables (standalone; however can be increased using switch or hub). Once booted various LED indicators are present to show progress of router. The router is also linux based. It has embedded HTTP, DNS and SCCP server. The nmap output says it.

nandakumar@linux:~> sudo nmap -sT -O 192.168.11.0/24

root's password:

Starting Nmap 5.21 ( http://nmap.org ) at 2011-09-04 15:39 IST

Nmap scan report for 192.168.11.1

Host is up (0.0071s latency).

Not shown: 996 closed ports

PORT STATE SERVICE

53/tcp open domain

80/tcp open http

2000/tcp open cisco-sccp

49152/tcp open unknown

MAC Address: 4C:E6:76:4D:F6:90 (Unknown)

Device type: general purpose

Running: Linux 2.6.X

OS details: Linux 2.6.15 - 2.6.27

Network Distance: 1 hop

By default router has static IP of 192.168.11.1. It assigns the LAN members with IP with network-id 192.168.11.0.

(Caution: Please do not use nmap scan in WAN/(organisation LAN) environment. It is not legal in INDIA. I ran the command since it was in my own LAN environment.)

Setting up Wireless:

Before nmap or any other things can be done, we need to setup wireless network in the linux-box. The default wireless modules do not work properly or do not work. We need to obtain the vendor specific driver of our system and compile the code against native kernel and deploy it. In my case the wireless hardware was from broadcom corporation.

nandakumar@linux:~> /sbin/lspci

00:00.0 Host bridge: Intel Corporation Mobile 4 Series Chipset Memory Controller Hub (rev 07)

00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)

00:02.1 Display controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)

00:1a.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 (rev 03)

00:1a.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5 (rev 03)

00:1a.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6 (rev 03)

00:1a.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2 (rev 03)

00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 03)

00:1c.0 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 1 (rev 03)

00:1c.1 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 2 (rev 03)

00:1c.2 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 3 (rev 03)

00:1c.4 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 5 (rev 03)

00:1d.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 03)

00:1d.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 03)

00:1d.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 03)

00:1d.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 03)

00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 93)

00:1f.0 ISA bridge: Intel Corporation ICH9M LPC Interface Controller (rev 03)

00:1f.2 SATA controller: Intel Corporation ICH9M/M-E SATA AHCI Controller (rev 03)

00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 03)

09:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8040 PCI-E Fast Ethernet Controller (rev 13)

0c:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g LP-PHY (rev 01)

In my case it is BCM4312. Visit broadcom site and download the appropriate driver (32 or 64 bit depending on OS build version) for BCM4312 and compile against kernel. The README gives complete steps on how to patch, compile and deploy wireless module.

Once the wireless module successfully deployed, the NetworkManager shows up the new interface that is detected. I have disabled NetworkManager and used traditional ifup method. Once setup, goto

Yast->Network Devices->Network Settings

In the Overview Tab, select the interface which is wireless and click Edit.

Under Address TAB, configure interface to obtain address from DHCP. This option provides IP for the interface from wireless router. Once this is done, the wireless interface gets IP from router. Then connect to the router with router IP (in my case 192.168.11.1) and configure router. For increased security, disable SSID broadcast and enable WPA encryption with AES algorithm and provide strong password. Make sure you change password at-least once in a month. Disabling SSID broadcast ensures that your router is not visible outside including to your laptop.

(Note: initially router will not have any security enabled and you can configure as it is i.e. system will be able to scan the wireless network successfully. However, the configuration of router is for tight security. You may skip the configuration section if you do not wish to have security however it is not recommended)

Once router setup is done, we need to get into the network device setup in YAST. Now after the DHCP settings which was done earlier, click next to setup the wireless Network. Here enter the SSID of your router (It will be either MAC or custom as configured by you in router web page). Enter security type of your router and the password for the router and click Next and then OK. Now the setup is done for your router and you are ready to connect to internet.

Now there is a problem. The Internet is in WAN environment and we are in LAN environment. The wireless router does everything for us to connect to internet. But how will linux machine identify that whatever is IP has to connect? For name resolution, router has DNS server however, once IP is obtained, the linux box will not have any idea where to connect for that IP.

To resolve the problem, we need to manually add route to the linux routing table. This is one of the drawback of linux system. We can do this by adding routing table entry manually to connect to internet.

sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.11.1 dev eth1

The above command adds roue entry to the kernel saying that any IP must be routed to the wireless router (which is 192.168.11.1 in my case).

If you follow above method, you will have to add the route every time system starts up. If you need to add the route permanently, you can configure the routing under Network Settings as mentioned in previous sections.

Hope this helps. Comments are always welcome