How do I add or change my server's IP address?


 

ifconfig eth0 - Display current IP address and setting for network interface called eth0

 

You can add IP address using ifconfig command itself, but its not recomended for production servers, because it doesn't save it permenantly. To test your new IP address, just enter command:

ifconfig eth0:0  5.199.161.5 netmask 255.255.255.0 up 

in this way you will activate your new IP as alias and can check if you can reach it from outside your server:

ping  5.199.161.5 

 

To make permanent changes and save new configuration you need to edit configuration file according to your Linux distribution.

 

For Red Hat based systems like Centos/Scientific linux you need to edit/create files as follows:

/etc/sysconfig/network-scripts/ifcfg-eth0 : First Ethernet card configuration file
/etc/sysconfig/network-scripts/ifcfg-eth1 : Second Ethernet card configuration file

 

DEVICE=eth0 # Or eth1 interface
BOOTPROTO=static
IPADDR=5.199.161.5 # There you need set your IP address
NETMASK=255.255.255.0
ONBOOT=yes

Also its temporally recomended  keep your old IP addresses, if you want to do that you need create aditional network confugurations files like:

 

/etc/sysconfig/network-scripts/ifcfg-eth0:0 

/etc/sysconfig/network-scripts/ifcfg-eth1:0

 

there you need save your old IP address:

 

IPADDR="77.79.12.77" # Your old IP address
NETMASK="255.255.255.0"

 

also you need update your gateway information:

/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=demo.balticservers.com
GATEWAY=5.199.161.1

 

Save and close the file. Restart networking:

/etc/init.d/network restart

 

For Debian based systems like Ubuntu linux you need to edit / create files as follows:

 

/etc/network/interfaces

 

iface eth0 inet static
address 5.199.161.5 # There you need set your IP address
netmask 255.255.255.0
network 5.199.161.0
broadcast 5.199.161.255
gateway 5.199.161.1

 

teporally recomended  keep your old IP addresses, if you want to do that you need edit /etc/network/interfaces cofiguration file and add:

 

iface eth0:0 inet static
address 77.79.12.77 # There you can set your old IP address
netmask 255.255.255.0
network 77.79.12.0
broadcast 77.79.12.255

 

Save and close the file. Restart the network:

/etc/init.d/networking restart

 

For servers running Windows Server 2008:

 

Click Start, and then click Control Panel.

In Control Panel, verify that Classic View is selected, and then double-click Network and Sharing Center.

In Network and Sharing Center, in Tasks, click Manage Network Connections.

In Network Connections, right-click the network connection that you want to configure, and then click Properties.

In Local Area Connection Properties, in This connection uses the following items, select Internet Protocol Version 4 (TCP/IPv4), and then click Properties. The Internet Protocol Version 4 (TCP/IPv4) Properties dialog box opens.

In Internet Protocol Version 4 (TCP/IPv4) Properties, on the General tab, click Use the following IP address. In IP address, type the IP address that you want to use.

Press tab to place the cursor in Subnet mask. A default value for subnet mask is entered automatically. Either accept the default subnet mask, or type the subnet mask that you want to use.

In Default gateway, type the IP address of your default gateway.

In Preferred DNS server, type the IP address of your DNS server. If you plan to use the local computer as the preferred DNS server, type the IP address of the local computer.

In Alternate DNS Server, type the IP address of your alternate DNS server, if any. If you plan to use the local computer as an alternate DNS server, type the IP address of the local computer.

Click OK, and then click Close.

 

If you have other Unix/Linux distribution you should read documentation about your network configuration. All information about network settings configuration you can found online in your OS vendor website.

Tags: Change IP address swap IP
Chuck Norris has counted to infinity. Twice.