We help IT Professionals succeed at work.

How to change UNIX IP ?

KG1973
KG1973 asked
on
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.
Comment
Watch Question

BRONZE EXPERT
Commented:
Change IP
ifconfig eth0 192.168.1.10

Change IP with netmask
ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up



BRONZE EXPERT

Commented:
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.
BRONZE EXPERT

Commented:
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.

Author

Commented:
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 ?
BRONZE EXPERT

Commented:
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

Author

Commented:
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

BRONZE EXPERT

Commented:
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"

Author

Commented:
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...


BRONZE EXPERT
Commented:
You're going to have to power cycle to put the IP back the way it was if you have no console or serial access to the machine.
TomuniqueSr. AIX Admin

Commented:
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.
BRONZE EXPERT

Commented:
@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.
Ernie GronblomCloud Systems Engineer

Commented:
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

Author

Commented:
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 ?

Author

Commented:
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
TomuniqueSr. AIX Admin

Commented:
Yes, you can have multiple IPs of different classes.  I just don't believe they can span the same subnet.


Ernie GronblomCloud Systems Engineer

Commented:
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.
Top Expert 2015

Commented:
Would be sweet if you post version of your Solaris.

Author

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

Author

Commented:
Its actually Solaris10.
Top Expert 2015

Commented:
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

Author

Commented:
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.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.