In this section, we want to make our Debian Linux server functional in your static IP environment. Let’s suppose that the IP details are as follows:
IPv4 IP 192.168.0.100
I am using the nano editor. You can use your preferred text editors such as vi, joe …
The first step is to make a backup of your original file.
This is to manually configure root credentials of the network config file.
mv /etc/network/interfaces /etc/network/interfaces.bak nano /etc/network/interfaces
The values will be changed as follows:
auto lo iface lo inet loopback #My IP description # IPv4 address iface eth0 inet static address 192.168.0.100 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1
For IPv6 these entries need to be added:
nano /etc/network/interfaces [...] #IPv6 address iface eth0 inet6 static address 2001:db8::c0ca:1eaf netmask 64 gateway 2001:db8::1ead:ed:beef
The DNS will be added in the file /etc/resolv.conf
nano /etc/resolv.conf PrefferredDNS 22.214.171.124 AlternateDNS 126.96.36.199
if resolv.conf is installed in a Debian system, the DNS entries will not work. In this case, you need to add the entries in /etc/network/interfaces file like below:
[....] #DNS configurations dns-nameservers 188.8.131.52 dns-nameservers 184.108.40.206
To check if resolv.conf is installed use this command:
dpkg -l | grep resolvconf
Note: DNS entries can only be entered in one of these files: /etc/network/interfaces or /etc/resolv.conf.
Our hostname is myserver.sample.com. Here is how to add it:
echo server1.example.com >/etc/hostname
Also add it here:
nano /etc/hosts [...] 127.0.0.1 localhost 192.168.0.1 myserver.sample.com myserver [...] /etc/init.d/hostname.sh start
To check the hostname use the below code, In both cases, the value must be the same:
hostname hostname -f
I want to create an alias for eth0 to be able to have multiple IP addresses. Here is how it goes:
nano /etc/network/interfaces [....] #IP Aliasing auto eth0:0 iface eth0:0 inet static name Ethernet alias LAN card address 192.168.0.109 netmask 255.255.255.0 broadcast 192.168.0.255 network 192.168.0.0
Note: The Gateway has no extra column you should use your own IP. We have used 192.168.0.109 for IP aliasing. After all is done, a restart of the network service is required:
service networking restart
You need to use this command on Debian 7:
When all is done, check by:
The output should be similar to:
root@server1:~# ifconfig eth0 Link encap:Ethernet HWaddr 20:89:84:c8:12:8a inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::2289:84ff:fec8:128a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:200197 errors:0 dropped:67 overruns:0 frame:0 TX packets:69689 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:64103748 (64.1 MB) TX bytes:14106191 (14.1 MB) Interrupt:16 eth0:0 Link encap:Ethernet HWaddr 20:89:84:c8:12:8a inet addr:192.168.0.108 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::2289:84ff:fec8:128a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Note: Your values are different than the above.