Archive for the tag 'Debian Server'

How to Change Hostname in a Debian Server?

Changing the Hostname in a Debian Server

Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh. So on a Debian based system we can edit the file /etc/hostname and change the name of the system and then execute the following, to make the change active.

/etc/init.d/hostname.sh start

The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script used hostname.sh).

How to bind secondary IP addresses in Debian Server.

There is slight difference in binding secondary IP addresses in Debian server to that of a Redhat Linux server.

Open file /etc/network/interfaces
Contents of the file looks like

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.xyx
gateway 192.168.0.1

Suppose we wants to add an IP 192.168.0.3 add the following to /etc/network/interfaces.

auto eth0:1
iface eth0:1 inet static
address 192.168.0.3
netmask 255.255.255.xyx
gateway 192.168.0.1

Now run the command

ifup eth0:1

This will add Ip 192.168.0.3 in ifconfig output.

To add next secondary IP the next set of entry should be

auto eth0:2
iface eth0:2 inet static
address 192.168.0.4
netmask 255.255.255.xyx
gateway 192.168.0.1

Then Run

ifup eth0:2

These IP addresses are bounded to eth0 that is to the first NIC.
If you wants to bind the IP to the second network card the entry should be eth1:1 instead of eth0:1

Finally check whether the IP addresses are listed in the ifconfig output.