LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Two network configurations (https://www.linuxquestions.org/questions/slackware-14/two-network-configurations-404358/)

Groucho 01-17-2006 03:17 AM

Two network configurations
 
Hi.
I have a little question.
I've a laptop with slackware 10.2 on it.
At work I have a network configuration with DHCP.
In another office I have to set manually a static IP to connect the laptop to the LAN.
So the question is: it is possible to have two network configurations and switch between them in a simple way?
Now I've made to version of all files having network informations. All times I connect my laptop I have to rename some of those files and reboot. :confused: :scratch:
Thanks a lot

piete 01-17-2006 03:54 AM

I've recently been supporting a friends effort to get onto Linux, and she had a similar problem with her wireless network. Obviously she needs to store one setup for home and one setup for uni.

As far as I am aware, there is no "network profile" or equivalent in Slackware. At least, if there is, it's so obfuscated that you'd never think to try it ;)

The solution I came up with for her was to mess with some of the /etc/rc.d scripts. I did the wireless equivalent of the following:

Code:

#################
# rc.inet1.conf #
#################

NETSWITCH = "home"

case "$NETSWITCH" in
home )
# Config information for eth0 @ home:
IPADDR[0]="192.168.0.69"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""
;;
work )
# Config information for eth0 @ work:
IPADDR[0]=""
NETMASK[0]=""
USE_DHCP[0]="yes"
DHCP_HOSTNAME[0]=""
;;
esac

Once you've done it, you can rerun the network script with: /etc/rc.d/rc.inet1 eth0_restart

Or if you have more than one physical card:

Code:

~# /etc/rc.d/rc.inet1 stop
~# /etc/rc.d/rc.inet1 start

I haven't tested it very thoroughly, so, please please please backup any files before modification!! I will accept no responsibility for typos in your variable names ;)

Good luck!
- Piete

Edit:

I forgot to mention, if you hadn't already worked it out, you can now flip between home/work by changing the variable NETSWITCH in your file and rerunning the script as above. Seems simple enough to me, but, I like to make sure there are no misunderstandings!

Groucho 01-17-2006 04:28 AM

Thanks for your reply.
I'll try immediately.
Cheers

cathectic 01-17-2006 06:48 AM

Another alternative which I use on my laptop is to replace /etc/rc.d/rc.inet1.conf with a symlink that points to another file (e.g. /etc/rc.d/rc.inet1.conf.home)

I then have another bash script called 'chnet' which takes the rc.inet1.conf extension (e.g. home), then switches the rc.inet1.conf symlink to the profile/ rc.inet1.conf.* I want to use and restarts rc.inet1

However, since I'm having trouble getting the network scripts to play nice with wpa_supplicant at the best of times, for now it's so-so (more useful for switching between wired networks for the moment).


All times are GMT -5. The time now is 08:51 PM.