On 5 Mar 2005, Raghul wrote:
> Hi,
> I am new to linux.I am having a problem in changing ip address. I
> use 192.168.1.1 ip and 203.155.548.1 . What i need is a script that can
> change the ip from 192... to 203... ip .Is it possible in linux?
Are you physically changing the networks that you are plugged into? Those
addresses belong to different classes.
Do you have two network cards that are each plugged into a different
network? Sounds to me like you have a computer that is connected to the
internet and one connected to a LAN. If this is the case you need to
assign one card one address and another card the other address. You can do
this with ifconfig (man ifconfig). You will also need to setup your
routing table with route so that the correct packets are transmitted to
the correct networks through the correct interfaces (network cards).
If all you need to do is change the IP address of the card, you can write
a script like this:
--cut--
#!/bin/bash
lan() {
echo -n $"Switching to 192 address."
ifconfig <ifconfig parameters that match your needs>
}
wan() {
echo -n $Switching to WAN address."
ifconfig <ifconfig parameters that match your needs>
}
case "$1" in
lan)
lan
;;
wan)
wan
;;
*)
echo $"Usage: $0 {lan|wan}"
exit 1
esac
exit 0
--cut--
-jackery
|