Link to home
Start Free TrialLog in
Avatar of frankbustos
frankbustosFlag for United States of America

asked on

How to change ip address on Linux server

Hi Experts,

  I have a linux server with a static ip address of 10.10.2.36. I would like to change to a different address. I'm at the following prompt, please note I have no experience with Linux, I just want to change the ip address.

[root@nglinux04]#

Avatar of mrcannon
mrcannon
Flag of United States of America image

Each distro has it's own GUI methods however...

this command will set ip address of ethernet adapter eth0 to 192.168.1.5
# ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up
# ifconfig eth0

To make permanent changes to IP address you need to edit configuration file according to your Linux distribution.

Avatar of frankbustos

ASKER


ok, this is my windows ipconfig/all
IP Address. . . . . . . . . . . . : 192.168.89.155
Subnet Mask . . . . . . . . . . . : 255.255.254.0
Default Gateway . . . . . . . . . : 192.168.88.1
DHCP Server . . . . . . . . . . . : 192.168.88.12
DNS Servers . . . . . . . . . . . : 192.168.88.2
                                    172.21.0.12
                                    172.21.1.10
Primary WINS Server . . . . . . . : 10.2.102.4
Secondary WINS Server . . . . . . : 10.2.102.5


I  typed in this command #root: vi /etc/sysconfig/network-scripts/ifcfg-eth0 and I'm now editing but need to know the broadcast address and network address?
Network address is x.x.x.0
Broadcast address is x.x.x.255

All the numbers from x.x.x.1 - 254 are for your use on the LAN.
ASKER CERTIFIED SOLUTION
Avatar of furetto
furetto
Flag of Italy 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 prefered method is not ifconfig now days. It's "ip".

ip addr change 192.168.89.155/23 dev eth0

check with "ip addr" to see that it is correct.

For permanent changes you should do as suggested in /etc/.....

To get the broadcast address and such install sipcalc and do this.

sipcalc 192.168.89.155 255.255.254.0
or
sipcalc 192.168.89.155/23

You'll get this
-[ipv4 : 192.168.89.155/23] - 0

[CIDR]
Host address            - 192.168.89.155
Host address (decimal)  - 3232258459
Host address (hex)      - C0A8599B
Network address         - 192.168.88.0
Network mask            - 255.255.254.0
Network mask (bits)     - 23
Network mask (hex)      - FFFFFE00
Broadcast address       - 192.168.89.255
Cisco wildcard          - 0.0.1.255
Addresses in network    - 512
Network range           - 192.168.88.0 - 192.168.89.255
Usable range            - 192.168.88.1 - 192.168.89.254


If you're on a debian-based thing do this:
apt-get install sipcalc

suse:
zypper in sipcalc

on red had/centos/fedora you already have ipcalc
do this and you'll get almost the same result
ipcalc 192.168.0.1/23
you dont have to enter the broadcast and network addresses, the system can work them out for you.
thanks for your expert help!