LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-28-2008, 03:42 PM   #1
sneaky
Member
 
Registered: Aug 2008
Distribution: Fedora 9 Server
Posts: 51

Rep: Reputation: 15
1 Laptop needs setting uo for work and home


I use my laptop at home and work and I do not want to keep changing default gateways, ip ranges and dns's etc what is the best way to get round this.

Thanks

Chris

Also if I have an ip address of 172.16.0.13 and a linksys broadband router of 192.168.1.1 how do make them talk to each so that I can access the internet.
 
Old 08-28-2008, 04:12 PM   #2
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
I actually use two scripts that I coded up, one for use at work, and one for at home. Of course these are greatly simplified, but you get the idea.

Code:
# cat home
#!/bin/bash
ifconfig eth0 down
ifconfig wan0 down
ifconfig eth0 up 
ifconfig eth0 192.168.2.14 255.255.255.0
route add default gw 192.168.2.1
echo "192.168.2.1" > /etc/resolv.conf

# cat work
#!/bin/bash
ifconfig eth0 down
ifconfig wan0 down
iwconfig wan0 ESSID="Work AP" AP="blah" key="Secret"
ifconfig wan0 up
ifconfig wan0 194.16.8.37 255.255.248.0
route add default gw 194.16.8.16
echo "194.16.8.16 > /etc/resolv.conf
As to how to get your router and computer talking, if they're on different subnets (172.16 and 192.168) you're likely to have problems. The easiest method may be to run your dhcp client daemon (`dhcpcd` on Slackware) and pick up an address and DNS settings directly from the router in question.
 
Old 08-28-2008, 04:18 PM   #3
sneaky
Member
 
Registered: Aug 2008
Distribution: Fedora 9 Server
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks for the scripts.

I am a novice Linux person so excuse the daft questions.

1)What do I call the files including extensions.

2)Which Directory do I put them in.

3)How and when do I run the one I want.

I have just had a thought is it possible to use network manager and use the wired connection for work and the wireless for home.

Chris
 
Old 08-28-2008, 04:38 PM   #4
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
I tend to use the GUI as little as possible -- perhaps that's due to my Slackware background, which is why I have actually never used the network manager.

You may put these scripts really anywhere you'd like -- I myself just keep them in root's home directory (/root), for easy access when I `su` to root. Before using the above scripts for your own setup, make sure to read the ifconfig man page, and if applicable (for wireless), iwconfig.

To write those scripts, I just opened up vi (a text-editing program) from the command line and entered the above, saving the first as 'home' and the second as 'work'. You have to make sure they are executable, by using the `chmod` program. Again, read its man page for additional help. Unlike in Windows, there is no specific extention that makes a script or program executable; it's all handled through the file's permissions, which again are edited by `chmod`.

To execute those commands, I just run `su -c "/root/home"` or `su -c "/root/work"` as necessary. Others may have their own favored methodologies for doing this, but mine works for me and is fairly straightforward. The important part is that these files have to be run as root, because normally ifconfig, iwconfig, route, and resolv.conf aren't able to be accessed by normal, unprivileged users.

Also, if you update your profile information to include your distribution, it can help people here at LQ tailor their responses to your specific distro.

Last edited by Poetics; 08-28-2008 at 04:39 PM.
 
Old 08-28-2008, 04:43 PM   #5
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
I don't know what distribution you're using, but Mandriva has something called "Network profiles", configured in GUI from the Mandriva Control Center.
You should probably investigate and see if your distribution provides something equivalent.

Yves.
 
Old 08-28-2008, 04:55 PM   #6
sneaky
Member
 
Registered: Aug 2008
Distribution: Fedora 9 Server
Posts: 51

Original Poster
Rep: Reputation: 15
I use Fedora 9. I will update my profile.
I have set the files up and chmod 100 the files but when I try to run them with su -c "workh" it comes back with command not found.

Am I right in thinking I can setup the wired to one subnet and wireless to another.

Thanks for your time

Chris

Last edited by sneaky; 08-28-2008 at 05:23 PM.
 
Old 08-28-2008, 05:42 PM   #7
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
That you can -- something with using su -c however is that you need to tell it exactly where the file is, since it's likely not in your PATH. If your 'workh' is in /root, try `su -c "/root/workh"` instead.
 
Old 08-28-2008, 06:03 PM   #8
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,078

Rep: Reputation: 195Reputation: 195
Why don't you just use DHCP? Your router will offer it, chances are where you work does too.
 
Old 08-28-2008, 06:12 PM   #9
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 8 Jessie
Posts: 1,688
Blog Entries: 5

Rep: Reputation: 163Reputation: 163
I second the recommendation for DHCP. If you want a static IP at home, then you can configure your DHCP server (probably your router) to always serve up the same IP address for your laptop's MAC address.
 
Old 08-28-2008, 06:46 PM   #10
sneaky
Member
 
Registered: Aug 2008
Distribution: Fedora 9 Server
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks boys.

That is what I decided to do - seems like much less hassle.

Thanks for all your advice

Chris
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Setting up VNC to access home computer from work through corporate network gopi.d Linux - Networking 2 12-19-2007 05:55 PM
Apache Root/Home Directory and setting up FTP for home directories? Mankind75 Linux - Newbie 6 07-23-2006 03:37 PM
Need help setting up VNC from ISA server at work to desktop at home jrh008 Linux - Networking 1 08-04-2005 06:50 PM
Redhat 9 Laptop connects to internet at work, not at home nuttycad Linux - Newbie 1 03-18-2004 12:22 AM
Setting up a home network gi13s Linux - Networking 1 08-06-2001 09:37 AM


All times are GMT -5. The time now is 11:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration