LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-16-2006, 11:56 AM   #1
halfpower
Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 241

Rep: Reputation: 31
Toggling Network Devices


I have been connecting to my router by means of a cat 5 ethernet cable. I also have a wireless card. I have the kernel module loaded and the card is configured to use with a specific wireless basestation. How do I command my computer to use the wireless card instead of the ethernet card?

I'm using SW 10.2 with kernel 2.4.x. Below is the output of 'lsmod.' The wireless card module is rt2500, and the ethernet card is sk98lin.

Code:
$ lsmod
Module                  Size  Used by    Not tainted
rt2500                166016   2
ntfs                   51232   1 (autoclean)
keybdev                 1892   0 (unused)
mousedev                4020   1
hid                    20868   0 (unused)
usbmouse                1880   0 (unused)
input                   3200   0 [keybdev mousedev hid usbmouse]
usb-storage            62432   0 (unused)
ohci1394               23888   0 (unused)
ieee1394               41636   0 [ohci1394]
uhci                   24284   0 (unused)
ehci-hcd               17516   0 (unused)
usbcore                59148   1 [hid usbmouse usb-storage uhci ehci-hcd]
pcmcia_core            39172   0
ide-scsi                9392   0
sk98lin               141768   1
-hfp

Last edited by halfpower; 06-16-2006 at 11:59 AM.
 
Old 06-16-2006, 01:25 PM   #2
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
All you should have to do is change your rc.inet1.conf DHCP info and then restart rc.inet1

On my laptop, eth0 is my ethernet card and eth1 is my wireless card. So, if I want to switch from wireless to LAN, I remove the "yes" from "USE_DHCP[1]" and add a "yes" to USE_DHCP[0]

Then /etc/rc.d/rc.inet1 restart

Vice-versa if you want to go from LAN to wireless. I've made a /sbin/network script that does everything for me. I have several wireless hotspots that I connect to and I got tired of modifying my rc.wireless.conf and rc.inet1.conf...

In case you are even remotely interested, I'll post it. It's extremely amaturish and overly long but it get's the job done. This is on my own SysVinit Slackware version so locations/names of the files are different than where Slackware puts them. But that's easy enough to change to suit Slackware.

wireless.conf
Code:
# Wireless LAN adapter configuration

VERBOSE=1

case "$HWADDR" in

*)
    # Home:
    ESSID="MadPenguin"
    KEY="b576bdcba1773df06422ac55cb"

    # Gypsy Cafe:
    #ESSID="2WIRE230"

    # Gwen's Airport:
    #ESSID="Any"
    #KEY="421a0f733138f3c93ba20b6089"

    # Beth:
    #ESSID="synapse"
    #KEY="9dd0414685b6ea173a001b7063"

    MODE="Managed"
    ;;
esac
/sbin/network
Code:
#!/bin/sh

cd /etc/sysconfig

case "$1" in

###############################################################################
   home)

echo "Connecting to Home Network..."
# Uncomment the particulars:
if grep '#ESSID="MadPenguin"' wireless.conf 1> /dev/null 2> /dev/null ; then
   sed -i 's@#ESSID="MadPenguin"@ESSID="MadPenguin"@g' wireless.conf
fi
if grep '#KEY="b5' wireless.conf 1> /dev/null 2> /dev/null ; then
   sed -i 's@#KEY="b5@KEY="b5@g' wireless.conf
fi
# Comment the rest:
if grep '#ESSID="2WIRE230"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="2WIRE230"@#ESSID="2WIRE230"@g' wireless.conf
fi
if grep '#ESSID="Any"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="Any"@#ESSID="Any"@g' wireless.conf
fi
if grep '#ESSID="synapse"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="synapse"@#ESSID="synapse"@g' wireless.conf
fi
if grep '#KEY="42' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="42@#KEY="42@g' wireless.conf
fi
if grep '#KEY="9d' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="9d@#KEY="9d@g' wireless.conf
fi
cat << EOF > /etc/resolv.conf
nameserver 192.168.2.1
search Iceberg
EOF
/etc/rc.d/init.d/inet1 restart
	;;

###############################################################################
   gypsy)

echo "Connecting to Gypsy Cafe Network..."
# Uncomment the particulars:
if grep '#ESSID="2WIRE230"' wireless.conf 1> /dev/null 2> /dev/null ; then
   sed -i 's@#ESSID="2WIRE230"@ESSID="2WIRE230"@g' wireless.conf
fi
# Comment the rest:
if grep '#ESSID="MadPenguin"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="MadPenguin"@#ESSID="MadPenguin"@g' wireless.conf
fi
if grep '#ESSID="Any"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="Any"@#ESSID="Any"@g' wireless.conf
fi
if grep '#ESSID="synapse"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="synapse"@#ESSID="synapse"@g' wireless.conf
fi
if grep '#KEY="42' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="42@#KEY="42@g' wireless.conf
fi
if grep '#KEY="b5' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="b5@#KEY="b5@g' wireless.conf
fi
if grep '#KEY="9d' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="9d@#KEY="9d@g' wireless.conf
fi

cat << EOF > /etc/resolv.conf
nameserver 192.168.1.254
search gateway.2wire.net
EOF
/etc/rc.d/init.d/inet1 restart
        ;;

###############################################################################
   gwen)

echo "Connecting to Gwen's Airport Network..."
# Uncomment particulars:
# Why do people put whitespace in their ESSID?
if grep '#ESSID="Any"' wireless.conf 1> /dev/null 2> /dev/null ; then
   sed -i 's@#ESSID="Any"@ESSID="Any"@g' wireless.conf
fi
if grep '#KEY="42' wireless.conf 1> /dev/null 2> /dev/null ; then
   sed -i 's@#KEY="42@KEY="42@g' wireless.conf
fi
# Comment the rest:
if grep '#ESSID="MadPenguin"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="MadPenguin"@#ESSID="MadPenguin"@g' wireless.conf
fi
if grep '#ESSID="2WIRE230"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="2WIRE230"@#ESSID="2WIRE230"@g' wireless.conf
fi
if grep '#ESSID="synapse"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="synapse"@#ESSID="synapse"@g' wireless.conf
fi
if grep '#KEY="b5' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="b5@#KEY="b5@g' wireless.conf
fi
if grep '#KEY="9d' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="9d@#KEY="9d@g' wireless.conf
fi
/etc/rc.d/init.d/inet1 restart
	;;

###############################################################################
   beth)

echo "Connecting to Beth's network..."
# Uncomment the particulars:
if grep '#ESSID="synapse"' wireless.conf 1> /dev/null 2> /dev/null ; then
   sed -i 's@#ESSID="synapse"@ESSID="synapse"@g' wireless.conf
fi
if grep '#KEY="9d' wireless.conf 1> /dev/null 2> /dev/null ; then
   sed -i 's@#KEY="9d@KEY="9d@g' wireless.conf
fi
# Comment the rest:
if grep '#ESSID="MadPenguin"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="MadPenguin"@#ESSID="MadPenguin"@g' wireless.conf
fi
if grep '#ESSID="2WIRE230"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="2WIRE230"@#ESSID="2WIRE230"@g' wireless.conf
fi
if grep '#ESSID="Any"' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@ESSID="Any"@#ESSID="Any"@g' wireless.conf
fi
if grep '#KEY="b5' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="b5@#KEY="b5@g' wireless.conf
fi
if grep '#KEY="42' wireless.conf 1> /dev/null 2> /dev/null ; then
   true
else
   sed -i 's@KEY="42@#KEY="42@g' wireless.conf
fi
cat << EOF > /etc/resolv.conf
domain Belkin
nameserver 192.168.2.1
EOF
/etc/rc.d/init.d/inet1 restart
	;;

###############################################################################
ethernet)

# Set up the particulars:
sed -i '/USE_DHCP\[0\]/s/""/"yes"/g' inet1.conf
# Blank the rest:
sed -i '/USE_DHCP\[1\]/s/"yes"/""/g' inet1.conf
sed -i '/USE_DHCP\[2\]/s/"yes"/""/g' inet1.conf
sed -i '/USE_DHCP\[3\]/s/"yes"/""/g' inet1.conf
# Don't cat a reslov.conf. dhcpcd SHOULD handle that.
# We could be attempting to connect to ANY network.
/etc/rc.d/init.d/inet1 restart
# Default inet1.conf back to wireless for the next call:
sed -i '/USE_DHCP\[0\]/s/"yes"/""/g' inet1.conf
sed -i '/USE_DHCP\[1\]/s/""/"yes"/g' inet1.conf
	;;

###############################################################################
   scan)

	iwlist scan
	;;

###############################################################################
   help)

	echo
	echo "Usage for 'network' script :"
	echo
	echo "help     - Prints this help list"
	echo "home     - Connect via wireless to your home network"
	echo "gypsy    - Connect via wireless to the Gypsy Cafe network"
	echo "gwen     - Connect via wireless to Gwen's network"
	echo "beth     - Connect via wireless to Beth's network"
	echo "ethernet - Connect via ethernet cable to any network using DHCP"
	echo "scan     - Scan the air for available wireless networks"
	echo "           Will not work if connected via ethernet"
	echo
	;;

###############################################################################
      *)

	echo
	echo "Usage: network {help|home|gypsy|gwen|beth|ethernet|scan}"
	echo
	exit 1
	;;
esac
Isn't that the most absurdly sloppy thing you've ever seen? Hey... It works...

This is on a Powerbook so my airport card is supported under the kernel. rc.inet1.conf has support for wireless devices assigned as wlan0 if it happens to have that designation under ifconfig/iwconfig..

You can also call rc.inet1 with specific device arguements...
/etc/rc.d/rc.inet1 eth0_start

Last edited by jong357; 06-16-2006 at 03:37 PM.
 
Old 06-16-2006, 03:04 PM   #3
halfpower
Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 241

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by jong357
Isn't that the most absurdly sloppy thing you've ever seen? Hey... It works...
I couldn't say. I'm new to this scripting business.

Thank you for the informative post.
 
Old 06-16-2006, 05:06 PM   #4
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Rep: Reputation: 45
You can also start and stop the devices individually once it is set up correctly in the rc.inet1.conf:
Code:
sh /etc/rc.d/rc.inet1.conf eth0_stop
sh /etc/rc.d/rc.inet1.conf eth1_start
This would keep you from having to modify rc.inet1.conf each time.

regards,
...drkstr

Last edited by drkstr; 06-16-2006 at 05:11 PM.
 
Old 06-16-2006, 05:58 PM   #5
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
You could try and see if this: http://www.slackware.com/~alien/rc_scripts/ifcfg/ makes sense to you. It is a solution I wrote for my laptop, where I needed mobility. Using the provided scripts from that link, I can now switch from "wired" to the wireless interface by just unplugging the network cable. After re-plugging of the cable, the laptop will automatically switch back to the faster cable network connection.

It requires you to replace rc.inet1 with an enhanced version. You should be comfortable with doing this, and make backups in case it does not work at the end.

I have feedback from several users that my solution works nicely for them - you'll find it mentioned in this very forum, too.

Eric
 
Old 08-13-2006, 08:30 PM   #6
halfpower
Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 241

Original Poster
Rep: Reputation: 31


I tried doing what jong357 and Drkstr suggested but it did not seem to work. I can insert the module with a script I wrote and I can disable my cat5 connection. My wireless card has the ifname "ra0" but it does not use the rc.wireless.conf file. The module has its own configuration file located at /etc/Wireless/RT2500STA/RT2500STA.dat. This is what my /etc/rc.d/rc.inet1.conf file looks like.

Code:
# Config information for eth0:
IPADDR[0]=""
NETMASK[0]=""
USE_DHCP[0]="yes"
DHCP_HOSTNAME[0]=""

IPADDR[1]=""
NETMASK[1]=""
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""

# Config information for eth2:
IPADDR[2]=""
NETMASK[2]=""
USE_DHCP[2]=""
DHCP_HOSTNAME[2]=""

# Config information for eth3:
IPADDR[3]=""
NETMASK[3]=""
USE_DHCP[3]=""
DHCP_HOSTNAME[3]=""

# Default gateway IP address:
GATEWAY=""

# Change this to "yes" for debugging output to stdout.  Unfortunately,
# /sbin/hotplug seems to disable stdout so you'll only see debugging output
# when rc.inet1 is called directly.
DEBUG_ETH_UP="no"

## Example config information for wlan0.  Uncomment the lines you need and fill
## in your info.  (You may not need all of these for your wireless network)
IFNAME[4]="ra0"
#IPADDR[4]=""
#NETMASK[4]=""
USE_DHCP[4]="yes"
I tried use the wireless card by typing "sh /etc/rc.d/rc.inet1 ra0_start." It did something, but I'm still lost, as I still could not connect.
 
  


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
toggling touchpad BCarey Linux - Laptop and Netbook 5 05-12-2006 12:10 PM
DCOP kmix - Toggling mute mickyg Linux - Software 1 12-13-2005 03:37 AM
Toggling rc.firewall between ppp0 and eth0 Woodsman Slackware 2 12-05-2005 07:33 PM
script to change KMix; strange toggling effects shengchieh Linux - Software 0 10-07-2005 12:55 PM
issue with toggling out of fullscreen FCE Ultra 0.98-13 Kilahchris Linux - Software 1 05-22-2005 10:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:27 AM.

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