Link to home
Start Free TrialLog in
Avatar of KG1973
KG1973

asked on

How to change UNIX IP ?

Currently I have 2 networks : ( 1 for windows PC and other for Unix )
Windows PC use Class A and Unix class B).

Windows server use the following IP :

10.149.13.1
subnet 255.255.255.0
def gateway 10.149.1.1

This server run well and can use internet access using assigned gateway.


Now, I want to configure my unix server (seperate network) to join above network
current IP is:

ifconfig -a

e1000g0: inet 172.20.33.2 netmask ffff0000 broadcast 172.20.255.255

How can I change the IP similar to my windows server.

New IP 10.149.13.2
subnet 255.255.255.0
def gtway 10.149.1.1


What command should I use, how to ping itself and to windows server and
how to undo if something goes wrong ?

Also, the problem that I have now is, I can only access this unix server using telnet 172.20.33.2.
The monitor and keyboard attached to this unix box, is not working. This will be my first time
to change unix IP, so I really need your help, step-by-step guide.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The above commands will not persist after reboot.  You can issue the same kind of command to reassign the old IP.

You can ping your own IP or any other
ping <IP>

EG
ping 192.168.1.10

As soon as you change your IP, you will lose your connection.  It is a little risky if you are remotely connecting because you may "lock yourself out" if something didn't work.
You should have at least one more IP and interface configured or you should have some other remote console in case you lock yourself out like KVM, etc.
Avatar of KG1973
KG1973

ASKER

Thanks for quick reply.
>>As soon as you change your IP, you will lose your connection.  It is a little risky if you are remotely
>>connecting because you may "lock yourself out" if something didn't work.

That is is what I am worry about. Can we assign additional IP ? Retain the original one. Is this possible ?

For 1st try, I will change it using same class.
ifconfig eth0 172.20.33.3 netmask 255.255.255.0 up

How about default gateway IP ? How can this server access Internet ?
If you have physical access to the system or a remote console, you have nothing to worry about.

You generally can give additional IP addresses to the same interface.
Like try
ifconfig eth0:1 172.20.33.3 netmask 255.255.255.0 up
Avatar of KG1973

ASKER

I just changed it 172.20.33.3
ifconfig e1000g0 172.20.33.3 up

But when I display current ip, ifconfig -a
it does not show old ip anymore. (it is not adding new IP but replace it instead)

So If I add new Ip using
ifconfig e1000g0 10.149.13.2 up
it will change the IP but I am bit worry if I can't connect because I will change the cable to
connect to Class A switch and try to ping to our router

I am confused with netmask vs subnetmask. What is broadcast IP for ? How to assign
def gateway ?

Unix server must have the following :
New IP 10.149.13.2
subnet 255.255.255.0
def gtway 10.149.1.1

If you're running Linux:

  route add default gateway x.x.x.x

If you're running Solaris, or other sysv derivative:

  route add default x.x.x.x

(where x.x.x.x is your gateway)

The broadcast is automatically determined by the netmask, so you don't have to set that.
For instance, if your IP is 10.149.13.2 and you configure a 255.255.255.0 netmask, then the broadcast can't be anything else other than 10.149.13.255 (which you will see in ifconfig of the interface)

If you say which version/distribution of Unix you're running, we can tell you how to make your changes permanent.  Type "uname -a" to find this out if you're not sure.  Also, you can do "cat /etc/issue" or "cat /etc/issue.net"
Avatar of KG1973

ASKER

uname -a
SunOS Myserver 5.10 Generic_137111-01 sun4v sparc SUNW,SPARC-Enterprise-T5220

#ifconfig e1000g0 10.149.13.2 netmask 255.255.255.0 up

the changes seems to work because its hang, disconnected

But then I connect the network cable to Class A switch. Then I try to ping
from PC in this network. I don't have any reply.
I don't think that I can telnet using old IP again even if I put back the cable
to previous switch before I change the IP to 10.149.13.2

Really need ur help. I cant use the terminal/keyboard/mouse to configure
directly to this unix server as I mention earlier...


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BE AWARE.... ifconfig on some systems does NOT last over a reboot.

I did't see where an OS was specified. but in AIX, you need it stored in the ODM to get the change to last over a reboot.

# smitty tcpip      # AIX ONLY

is the easiest way to get it done.  follow the screens.
@Tomunique:
ifconfig doesn't "last" on ANY systems after a reboot - that is why he needs to boot it to put it back on the old IP.
I question the default gateway address or your netmask.
New IP 10.149.13.2
subnet 255.255.255.0
def gtway 10.149.1.1

If your host is 10.149.13.2, with that subnet mask, it will not be able to communicate with 10.149.1.1 because it is outside of the 10.149.13.X range.

To make any changes permanent (last a reboot):
You need to update the /etc/hosts file.  You should also check the /etc/hostname.e1000g0 file.

To ADD an address, you can plumb a new address:
plumb e1000g0:1
ifconfig e1000g0:1 10.149.13.2 netmask 255.255.255.0 up
Avatar of KG1973

ASKER

The problem now is I totally cannot access to this box either remote or physical connection.
How can I revert back to Class B IP. I cant even power down the box neither to restart.

Is there anything I can do before I press small white button to force shutdown ?
Avatar of KG1973

ASKER

ok, now. I did shut it down the server which I don't like it but have no choice.

Now my IP back to 172.20.33.2

Can I have 2 IPs with different class ?
default ip = 172.20.33.2
extra ip = 10.149.1.2

Can I use the following? :
To ADD an address, you can plumb a new address:
plumb e1000g0:1
ifconfig e1000g0:1 10.149.1.2 netmask 255.255.255.0 up
Yes, you can have multiple IPs of different classes.  I just don't believe they can span the same subnet.


They can be of different classes or they can also be located within the same subnet.  Depending on the switch that the port is connected to, you may have a problem if the switch uses VLANs or other methods for segregating network traffic.

So, the interface will respond to either address, but you should check whether the switch that the port is connected to will allow both addresses without filtering it.
Would be sweet if you post version of your Solaris.
Avatar of KG1973

ASKER

uname -a
SunOS Myserver 5.10 Generic_137111-01 sun4v sparc SUNW,SPARC-Enterprise-T5220
Avatar of KG1973

ASKER

Its actually Solaris10.
yes yes... SunOS 2.6 was followed by SunOS2.7 aka Solaris 7 and it continues until today


in addition to ifconfig (plumb) ... up
you need to use "route add" command to add default gateway.
here is what you need to do to change an ip address on e1000g0
as root
ifconfig e1000g0 plumb #enables the card do not do it if it already works
ifconfig e1000g0 10.149.13.2 netmask 255.255.255.0 up
route change default 10.149.1.1 #this will change old default gw, you can alwas check routes with 'netstat -rn'

Try that and confirm here that it works. We will make it persistent across reboots if you like but first check that it works
Avatar of KG1973

ASKER

Thanks guys. I am now using new ip and since my unix's keyboard, mouse and monitor is working, I can always try it with different ip.