On Fri, 22 Aug 2008 06:16:01 GMT
aescott <aescott@no-mx.forums.opensuse.org> wrote:
>
> All machines at work (a University) must have static IPs for the wired
> network. There is a wireless dynamic network but it is sloooww…
>
>
Well DRAT! Well, if you’re not adverse to doing a little typing, you could
‘swap’ the config files as necessary to set up either dhcp or static as
needed.
Assuming your wired nic is ‘eth0’ in your laptop, then the DHCP setup is
stored at:
/etc/sysconfig/network/ifcfg-eth0
and when you’re at work, the STATIC setup is stored at:
/etc/sysconfig/network/ifcfg-eth0
{Grin} Same file! (it’s the contents that matter)
So if you were to make copies of that file during each ‘connection’, and just
drop the appropriate one in there and restart the network system… you’d be
just peachy without all the ‘reconfig’ heartache.
(you’ll need to be root for this)
Set up the system for DHCP access. Now copy the ifcfg-eth0 file to
dhcp-ifcfg-eth0 in the same subdir. (the system keys off of ‘ifcfg-eth0’ part,
so has to be in front)
Now, set up system as you require for STATIC access, and then copy the new
‘ifcfg-eth0’ file to ‘static-ifcfg-eth0’.
So now we have TWO files, one representing the STATIC setup, and one
representing the DHCP setup.
Now create two tiny scripts, one to copy the static version of ifcfg-eth0
into place and restart the network, and the other to copy the dhcp version
and restart.
Yes, the SCPM is supposed to do this, but it’s annoyingly painful to work
with. So we do this:
(the ‘\cp’ lines wrap due to the forum, it’s all one line)
First file: ‘setup-static’
#!/bin/bash
\cp /etc/sysconfig/network/static-ifcfg-eth0
/etc/sysconfig/network/ifcfg-eth0
rcnetwork restart
And second file: ‘setup-dhcp’
#!/bin/bash
\cp /etc/sysconfig/network/dhcp-ifcfg-eth0
/etc/sysconfig/network/ifcfg-eth0
rcnetwork restart
You’ll need to make them executable, so:
chmod +x setup-static setup-dhcp
and then need to put them into your path:
mv setup-static setup-dhcp /usr/local/bin
and to use them as your user:
sudo setup-static
–or–
sudo setup-dhcp
Did that make sense?
You would get to work, turn on laptop, log in, type ‘sudo setup-static’ and
the laptop would come up with the proper static IP. (you could create an
icon for this too!)
Get home, do the same, ‘sudo setup-dhcp’ (and again, an icon is easy!)
To use in an icon, use “kdesu setup-xxx” instead of sudo.
Hope this helps
Loni
–
L R Nix
lornix@lornix.com