# switching networks? how do i do it?

## jimlynch11

i have a laptop at school running gentoo...and it works marvelously when im plugged in in my room.  however whenever i take my laptop to class or a study room, the network always dies within a few minutes of booting up.  i can extend this by pinging google or something in the background continuously.

how do i configure my laptop so that i can unplug in my room, do ifconfig eht0 down, then go to another area on campus and do ifconfig eth0 up and itll just work as good as usual.  now i have to reboot normally just to get the ifconfig to come back up...am i doing something wrong? 

thanks in advance for the help!

----------

## jt42

have you looked at app-admin/quickswitch?

from the DESCription:

Utility to switch network profiles on the fly

having said this, I have two scripts set up that change my network settings to reflect my home and office settings.

Files that I change:

/etc/resolv.conf

/etc/hostname

/etc/hosts

I also change the network settings by calling ifconfig directly with the appropriate home/work settings

----------

## jimlynch11

alright thanks, i will check that out when i get back to my room (and back on gentoo)

is it possible that my school's network is big enough that there will be a different DHCP server for this location vs. the one in my room?

----------

## jimlynch11

is there a way i can have it set up similar to in windows w/ winipcfg...i want to be able to just hit release, then renew and have it detect all of my settings on the fly... quickswitch has alot of samba and printer related stuff that is unneccessary for me. plus, everytime i plug in to a new network i would have to make a new setting, which could get old quickly. thanks for the help

----------

## guero61

Pardon potential ignorance, but why mess with ifconfig when you can use the wrapper script /etc/init.d/net.eth0?  It can do everything ifconfig does, and does it with style!

----------

## jimlynch11

sounds ok to me...how do i make it do release/renew using net.eth0?

----------

## guero61

DHCP, you'd modify /etc/conf.d/net to dhcp instead of static IP.  Then, just "rc-update add net.eth0 default".

I'm a little confused -- are you using static IP's (sounds somewhat like it using ifconfig) or DHCP?  If DHCP, the init-script should work well enough.  If it doesn't, then just add this to your /etc/conf.d/local.start or wherever.

```

dhcpcd -k eth0

dhcpcd eth0

```

That forces dhcp to drop whatever IP it thinks it has, and request a completely new one.

You really shouldn't have to go through all of that; if you run DHCP on both networks, you should be able to swap between them seamlessly.  If you DON'T, you could always add another net.ethX script, and have one for your static setup, one for your DHCP setup.  Then just tell whichever one to start you want.

----------

## jimlynch11

yeah that didnt work, it still drops me after anywhere from 30 seconds to 5 minutes...what else can i try?

basically it seems like the big difference between my room and the other study area i go to is the default gateway.

in my room: *.*.255.255

in study area: *.*.254.254

i tried adding both to the net file but still no luck

----------

## guero61

???  Your default gateway is .255.255?  _THAT_ is strange.  what class network is it (give me an example IP if you don't know).

----------

## jimlynch11

according to WINIPCFG (winxp works fine so im assuming that this information is accurate):

Subnet Mask: 255.255.0.0

Default Gateway: 152.17.254.254 (study room)

Default Gateway: 152.17.255.255 (dorm room)

I had put in the stars before because i didnt think the first two fields of the gateway were relevant...although i think that mightve caused some confusion, i apologize...and thanks for the continued help   :Very Happy: 

----------

## guero61

It's just that... unless in a special network, any address ending in .255 is the broadcast address.  That means in your dorm room, if you don't have a routing entry, everything goes out blasted to the network, in hopes someone will send back the proper information.  

Most network equipment won't even let you assign the broadcast address.  Even so, that's another issue -- whoever designed your school's network is either a blithering idiot or stellar genius, well beyond my realm of networking.

The issue at hand is that your box is dropping it's network once it gets into a new environment.  Does eth0 go down, or does the interface just stop transmitting data?  Have you checked your logfiles to see anything going wrong?  You can always tell dhcpcd to run in debug mode, which will provide greater logging facilities.

----------

## jimlynch11

i _think_ it just stops transmitting data.  gaim and konqueror will die all of a sudden, and if im pinging something continuously in the background it will all of a sudden just kind of hang, and eventually say that there was no response.  doing an ifconfig though still shows that the eth0 is still up and running, which perplexes me.  which logfiles can i look in, and how do i run dhcpcd in debug? is it just an argument i can find in dhcpcd --help? or man dhcpcd?

if i do /etc/init.d/net.eth0 restart it will work again for another few mins, but then die again shortly thereafter

----------

## guero61

I'm not sure which, because it varies with the system logger.  Look in /var/log, and see if any of the files say anything.  

Yes, man dhcpcd shows the first argument -d to be some sort of debug switch; I just gave it a cursory glance.

If eth0 is still up, it's likely not dhcp that's the problem.  Look for another issue -- kernel ooops, something of the sort (check dmesg).

----------

## jimlynch11

alright thanks for the help again, and sorry for the newbie questions...

dmesg didnt seem to turn up any errors, it said e100 was working fine...i guess ill have to wait until tomorrow when im back at the other location to see what i can figure out

----------

## OdinsDream

I would suggest, since you are using gentoo, to use the /etc/init.d/net.eth0 script for your network ups and downs.

Check /etc/conf.d/net and look at the lines for your network card. Sounds like you're using eth0, and relying on a DHCP server to give you a configuration. Check to make sure that the line:

iface_eth0="dhcp"

is not commented, that is, preceeded with #.

Also, check to make sure that the line looking something like:

#iface_eth0="192.168.2.1 broadcast 192.168.2.255 netmask 255.255.255.0"

Is, indeed, commented. After this, you can either choose to have the computer boot up and look for an IP address, by doing:

rc-update add net.eth0 default

In any case, you can always execute the script by hand:

/etc/init.d/net.eth0 [start stop restart]

Choosing which of those three options you wish to perform. This is the method I use to handle networks on my laptop. Before unplugging, I do /etc/init.d/net.eth0 stop. Later, I start it at the new location. I have yet to have problems with this method.

You can verify that the settings have been retrieved correctly, of course, by executing /sbin/ifconfig, as you usually would.

----------

## jimlynch11

 *OdinsDream wrote:*   

> 
> 
> Also, check to make sure that the line looking something like:
> 
> #iface_eth0="192.168.2.1 broadcast 192.168.2.255 netmask 255.255.255.0"
> ...

 

for some reason this was not commented...perhaps this was my problem...i will try it tonight when i change locations.... thanks for the detailed and informative help

----------

## jimlynch11

yeah so i tried to comment that line and it still died...there is a heading at the bottom about the default gateways, should i perhaps put in my information there and uncomment that line? i cant understand what is causing so many problems

----------

## guero61

Processing... too many classes+support requests...  :Exclamation: 

----------

## Valen

What happened when you tried the /etc/init.d/net.eth0 restart OdinsDream suggested?  Can you post the output of /sbin/ifconfig and /sbin/route -v from both locations?

----------

## jimlynch11

when i restarted it using /etc/init.d/net.eth0 restart , it starts working for a little (30 seconds to a few minutes) but then dies again shortly thereafter.

in the location that works:

ifconfig

 *Quote:*   

> 
> 
> eth0      Link encap:Ethernet  HWaddr 00:D0:59:D8:13:F0  
> 
>           inet addr:152.17.135.222  Bcast:152.17.255.255  Mask:255.255.0.0
> ...

 

route -v

 *Quote:*   

> 
> 
> root@lyncjp0-pc lyncjp0 # /sbin/route -v
> 
> Kernel IP routing table
> ...

 

ill post the other non-functioning location when i get there in an hour or so, thanks in advance for the help

----------

