LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-03-2011, 04:58 AM   #1
Tux Rules
Member
 
Registered: Feb 2009
Location: at my place
Distribution: Arch
Posts: 153

Rep: Reputation: 25
how can I connect to a D-link DIR-300 router using command line


I need to connect to my router using only CLI, specifying an username and password, preferably with a single command line, so it won't be interactive, 'cause I need to include the command in a script.
 
Old 04-03-2011, 08:26 PM   #2
WildPossum
Member
 
Registered: Feb 2004
Location: Sydney - Australia
Distribution: Ubuntu, OpenSUSE, Mythbuntu, Embedded Linux
Posts: 46

Rep: Reputation: 18
Install and use 'lynx' its a web CLI that allows you to get into WEB based configuration pages on these types of modems.

Cheers.
 
Old 04-03-2011, 09:02 PM   #3
Peacedog
LQ Guru
 
Registered: Sep 2003
Location: Danville, VA
Distribution: Slackware, Windows, FreeBSD, OpenBSD, Mac OS X
Posts: 5,296

Rep: Reputation: 168Reputation: 168
Hi Tux Rules, Welcome to LQ. If your AP is open or WEP you could use wireless tools.

Code:
# iwconfig wlan0 essid yourrouter key yourkey
# dhclient wlan0
or if you use an ascii password

Code:
# iwconfig wlan0 essid yourrouter key :syourpassword
# dhclient wlan0
replacing wlan0 with your interface.

If your AP is WPA you'll need to look into wpa_supplicant. There are more options available for wireless tools and plenty information on wpa_supplicant in the man pages.

Good luck. ;-)
 
Old 04-04-2011, 02:03 AM   #4
Tux Rules
Member
 
Registered: Feb 2009
Location: at my place
Distribution: Arch
Posts: 153

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by WildPossum View Post
Install and use 'lynx' its a web CLI that allows you to get into WEB based configuration pages on these types of modems.

Cheers.
True , I've already used lynx for the rest of the script. Basically I've done a script that called through conky would display the number and IP's of those that are connected to the router I want to watch. For that I've used
Code:
lynx --dump path_to_routers_status
There's just one small probelm, lynx can't get passed routers autentification using just one command line. You have to launch it and log in to the routers interface interactivelly. After I log in to the routers interface using any web browser conky displays what I want but I want it to do it automatically, so I could quicly check the wireless network and just log out after I've finished.

Quote:
Originally Posted by Peacedog View Post
Hi Tux Rules, Welcome to LQ. If your AP is open or WEP you could use wireless tools.

Code:
# iwconfig wlan0 essid yourrouter key yourkey
# dhclient wlan0
or if you use an ascii password

Code:
# iwconfig wlan0 essid yourrouter key :syourpassword
# dhclient wlan0
replacing wlan0 with your interface.
It has to be done through an UTP cable, from the main computer for the reasons I've allready mentioned in my reply to WildPossum
 
Old 04-04-2011, 11:28 AM   #5
devwatchdog
Member
 
Registered: Jan 2010
Posts: 202

Rep: Reputation: 47
I'd be looking at 'wget'.

These are the flags you would be looking for:

Code:
--http-user=user
--http-password=password
           Specify the username user and password password on an HTTP server.
           According to the type of the challenge, Wget will encode them using
           either the "basic" (insecure), the "digest", or the Windows "NTLM"
           authentication scheme.
Although it sounds like you need something to display the results, too. You could save the URL as a file and open it with a browser I suppose.

What specifically is your concern? And how do you want this process to work? Do you intend to have a browser pop up every time this script runs? You could parse the file and strip out the bits you want to see and do it via text, which would eliminate the need for a browser.
 
Old 04-04-2011, 01:31 PM   #6
Tux Rules
Member
 
Registered: Feb 2009
Location: at my place
Distribution: Arch
Posts: 153

Original Poster
Rep: Reputation: 25
what I need is to see on my desktop when I start the computer the number of those connected to the wireless router their IPs and the signals percentage they use. All this is shown in the routers graphical interface that I can access through a web browser. For this I've used lynx, so it will dump the status section of the wireless network. Using awk I've managed to isolate only the parameters I've needed. But lynx, as far as I know, cannot automatically get passed the routers authentication that requires an user name and a password.

Therefore I have to log in the routers interface first, providing the right username and password so conky could display what I want to see. Now I would like to know if the authentication could be done only through a command or commands that I could incorporate in that script so everything would be done automatically without my intervention.

Anyway if there are other ways I could watch constantly the informations I need so passing through routers authentication won't be needed it would be great but that's the only solution I could think of.

By the way that script it's no biggie and it looks like this

Code:
#!/bin/sh

lynx http://router_adress/st_wlan.php --dump | grep NUMBER\ of\ WIRELESS\ CLIENTS
lynx http://router_adress/st_wlan.php --dump | awk '/11g/ {print "IP:"$2 " " "M:"$3 " " "Rate:"$4 " " "Signal(%):"$5}'
This is how conky looks, with only my laptop connected to the wireless network
http://img641.imageshack.us/img641/3994/67441188.png

If there's any other way to accomplish this I'm fine with it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
D-Link DIR-100/300/320 Lexus45 *BSD 1 01-25-2011 06:56 AM
Dell 1525 with fedora 13 and D-Link DIR 300 - no connection Mike Mather Linux - Laptop and Netbook 2 08-25-2010 06:19 PM
Should router dir 100 from D-link detect Linux hostname automatic? sysslack Linux - Networking 2 12-26-2009 12:09 PM
[SOLVED] ls -d --dereference-command-line-symlink-to-dir does not work as advertised jgombos Linux - General 2 09-03-2009 07:18 AM
how to connect 2 router d-link mido Linux - Networking 1 08-19-2008 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration