LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Anyone knows an applications that changes eth0 ip with a click? (https://www.linuxquestions.org/questions/linux-software-2/anyone-knows-an-applications-that-changes-eth0-ip-with-a-click-602534/)

huxflux 11-26-2007 02:36 PM

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!

Ephracis 11-26-2007 03:22 PM

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.

PTrenholme 11-26-2007 04:26 PM

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



All times are GMT -5. The time now is 12:02 PM.