Just after the installation, you must configure network in order to access your system from outside.
Most of operating systems provides instructions or options to setup network interface using command line.
On Linux systems we can directly modify network configuration files and make changes as per our requirements. This guide will help you to configure Network Interface on Ubuntu, Debian and LinuxMint systems.
1. Setup System Hostname
We can use ‘hostname‘ command to check current set hostname or to set new hostname of system.
Type hostname on command prompt and press enter to check current hostname of system.
hostname
Type new hostname with hostname command to set it. This will not remain after system reboot.
$ hostname newserver.com
To set hostname permanently, you need to edit /etc/hostname file and add new hostname.
nano echo "station1.example.com" > /etc/hostname
Now we need to edit /etc/hosts and bind new hostname with local ip address
127.0.0.1 localhost newserver.com
2. List Attached Network Interfaces
To check or list attached network interfaces on system use below command. This will also show the state of network interface.
ip addr
3. Configure IP Address on Interface
Now edit your network interface configuration file /etc/network/interfaces to configuring eth0 interface to get ip address from DHCP server and eth1 will have a static ip address.
nano /etc/network/interfaces
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet static address 192.168.8.121 netmask 255.255.255.0 gateway 192.168.8.1 dns-nameservers 8.8.8.8
4. Setup Virtual IP on Interface
Now if you want to add second ip address (virtual ip) on same interface (eth1). You can define alias in network configuration file and configure another ip address.
$ nano /etc/network/interfaces auto eth1:0 iface eth1:0 inet static address 192.168.8.122 netmask 255.255.255.0 gateway 192.168.8.1 dns-nameservers 8.8.8.8
5. Restart Network Service
After making all the changes just restart network service using below command.
$ /etc/init.d/networking restart
That’s all you have to do, Please Give your opinion below if you experience any issues or to discuss your ideas and experiences.