LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-26-2007, 03:36 PM   #1
huxflux
Member
 
Registered: Mar 2005
Posts: 33

Rep: Reputation: 15
Anyone knows an applications that changes eth0 ip with a click?


Hello all!

I own a laptop which i have t take it with me at work and bring it home in the evening.

The problem is i have to manually setup those IPs twice a day (dhcp is not avail).

Basically, i need something that stays in tray and if i right click it, a menu appears with options 'profile1' and profile2. when i click profile1, the program changes eth0's ip, gw dns and so on with some IPs i've attached to that profile.

clicking profile2 will change eth0 to a whole bunch of different ip addresses, these also preconfigured by me earyler.

if you don't know such program (if it doesn't exist), someone on freenode suggested i should use bash scripts. can anyone write the eth0-profile1.sh that once executed, it changes eth0 ips to:

ip 192.168.1.17
doh 255.255.255.0
gw 192.168.1.1
ns 192.168.100.1

and i'll do the eth0-profile2.sh (looking at what you wrote)

Thank you! Goodbye!
 
Old 11-26-2007, 04:22 PM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
Sounds like you could try NetworkManager.

There you can set properties on any given interface and then just click the icon in the taskbar and select which interface to use.

If you use KDE there is KNetworkManager.
 
Old 11-26-2007, 05:26 PM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,154

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
You don't mention the distribution you're using, nor why DHCP isn't working. Can you use your laptop "automatically" at a shop where WiFi is available for free? (Starbucks comes to mind.) If you can't, then I'd suspect that you've failed to install a DHCP client service, or don't have it automatically started. If this is the case, fixing the problem should fix your daily aggravation.

If you still want a "switch profiles" script, try this:
1) Backup your home and office ifcfg-eth0 files. (On my Fedora 7 system, there are three such files:
Code:
$ sudo find /etc | grep ifcfg-eth0
Password:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/networking/profiles/default/ifcfg-eth0
/etc/sysconfig/networking/devices/ifcfg-eth0
but they are all identical. Thus, to make a copy of my "home" cfg files, I could create a "home" directory (mkdir ~/home) use the command sudo cp /etc/sysconfig/networking/devices/ifcfg-eth0 ~/home/ and, after I'd connected to the "office" system, do the same. replacing "home" with "office." (The names are, of course, quite arbitrary).)

2) Once the backups are created, use a script like this: Warning: This is untested code!
Code:
#!/bin/bash
# Names used:
h=home
o=office
# Sanity check
sane=yes
if ! [ -f ~/$h/ifgfg-eth0 ]; do
  echo You have not yet created the ~/$h/ifcgf-eth0 file. >2;
  sane=no;
  done;
if ! [ -f /$o/ifcfg-eth0 ]; do
  echo You have not yet created the ~/$o/ifcfg-eth0 file. >2;
  sane=no
  done;
if [ sane = no ]; exit 1

#Copy the file to the three destinations
if [ $# != 1 ]; do echo You must supply exactly one argument, either "$h" or "$o." >2;exit;done
case $1 in
   "$h" | "$o )
   do
     sudo cp -f ~/$1/ifcfg-eth0 /etc/sysconfig/network-scripts/;
     sudo cp -f ~/$1/ifcfg-eth0 /etc/sysconfig/networking/devices/;
     sudo cp -f ~/$1/ifcfg-eth0 /etc/sysconfig/networking/profiles/default/;
   done;;
   *) do;
     echo "$1" is not a valid argument. Use "$h" or "$o." >2;
     exit 1;
   done;;
esac
 
  


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
Single-click, double-click icons in KDE Doug Vitale Linux - Newbie 5 07-23-2008 06:08 PM
CTRL+click, SHIFT+click no longer selecting multiple items General Linux - Hardware 1 05-20-2007 04:11 PM
Mapping CTRL+Click as right click using xmodmap in Modular X.Org 7 on Gentoo amitron Linux - General 0 10-12-2006 12:25 PM
mouse: single-click becomes double-click kinzlaw Linux - Hardware 2 08-24-2005 08:55 PM
Gnome 2.6.1: Single Click acts like Double Click Der_tolle_Emil Linux - Software 2 09-13-2004 09:59 AM


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