Easy way to switch network-configuration
Category: Linux RedHat9 Tips
Suppose You should regularly switch your computer network-configuration :
configuration A:
IP: 192.168.1.251, Mask: 255.255.255.0, Gateway: 192.168.1.1
configuration B:
IP: 192.168.1.252, Mask: 255.255.255.0, Gateway: 192.168.1.2
Sure you can do this:
- System-Setting -> Network
- Enter the desired IP, netmask, gateway, etc
- Save and close Network-Configuration-menu
- System-Setting -> Server-Setting -> Services: restart network
Do those sequence everytime you want to switch the config. Painfull?
There is other way to do those task. The fact is (for single ethernet card) the network-configuration is stored in file:
···etc/sysconfig/network-scripts/ifcfg-eth0
The idea is by saving ifcfg-eth0 then restore it when we should.
Saving configuration file:
- System-Setting -> Network
- Enter configuration A
- Save and close Network-Configuration menu
- Copy ifcfg-eth0 to other filename and other location e.g. /etc/mynetconfig:
···$ cp etc/sysconfig/network-scripts/ifcfg-eth0 /etc/mynetconfig/ifcfg-eth0-A
- Do similar sequence for configuration B.
···$ cp etc/sysconfig/network-scripts/ifcfg-eth0 /etc/mynetconfig/ifcfg-eth0-B
Restoring:
When you want to activate configuration A:
···$ cp /etc/mynetconfig/ifcfg-eth0-A etc/sysconfig/network-scripts/ifcfg-eth0
···$ /etc/init.d/network restart
You can make a batch script for those squence of commands. Remember, user should has root-access to run the script, but regular user can also run the script if they have been given permission. How ? We will discuss it latter.
1 Comments:
Happy New Year.. Raja :)
Post a Comment
<< Home