In this tutorial, I will show how to setup a basic network configuration inside Debian. The first thing you need to do is to boot up your Debian and log into the root account:
You may type ifconfig to display your current network configuration:
From the above picture, you can see that:
1) eth0 – is your first network interface card inside your server
2) lo – the loopback interface to access your local services such as proxy or webserver http://127.0.0.1
The network card settings can be found edit here:
vi /etc/network/interfaces
You may type this if you want to read more about the network settings help provided inside Debian:
man interfaces
SETUP STATIC IP
You may type like below inside your interface configuration file:
auto eth0
iface eth0 inet static
address 192.168.1.90
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
Please take note that only address and netmask is required to be inserted into the configuration. The gateway, network, and broadcast are optional. You may enter it or Debian will automatically calculate the other three based on your address and netmask.
SETUP DHCP
In order to setup DHCP for the network interface card, just type like below inside the /etc/network/interfaces file:
auto eth0
iface eth0 inet dhcp
CONFIGURE DNS
Next is to configure the DNS in order for it to resolve your domain name request into IP for the server to understand it. To configure, type:
vi /etc/resolv.conf
Then you may add any DNS you want inside the file:
nameserver 8.8.8.8
nameserver 202.75.34.2
nameserver 4.2.2.2
RESTART THE NETWORK SERVICE
After finished editing any of the network setting, you need to restart the network service in order for new changes to take effect. To restart, type:
/etc/init.d/networking restart
You may type ifconfig to see your new network settings:
You also may test ping a domain name to see whether your network settings is working or not by typing:
ping google.com
If you got the reply, this means your setup was successful.
ASSIGN MULTIPLE IP IN NETWORK INTERFACE CARD
The procedure would be the same like adding normal IP address to the network interface card. Just open up the network interface card settings by typing:
vi /etc/network/interfaces
Then add these following lines (depending on how much additional IP you want to add):
auto eth0 eth0:1 eth0:2
iface eth0 inet static
address 192.168.1.90
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
iface eth0:1 inet static
address 192.168.1.211
netmask 255.255.255.0
iface eth0:2 inet static
address 192.168.1.212
netmask 255.255.255.0
After saving and restarting the network, you can check your new setting by typing ifconfig