To setup static IP in Debian is a bit difficult as it has no TUI for networking setup. So to setup static IP in Debian, you need to modify file manually.
To setup static IP in Debian follow the steps below:-
- First, we need to modify /etc/networking/interfaces files, so we make a backup before we perform any edit.
1$ sudo cp /etc/networking/interfaces /etc/networking/interfaces.bak
** If you do not have this file, you will use /etc/network/interfaces for the above and rest of the steps below
- Then, we edit the file at /etc/networking/interfaces
1$ sudo vi /etc/networking/interfaces
- Put in the content below into the file and save it:-
123456789101112131415161718# The loopback interfaceauto loiface lo inet loopback# The first network card - this entry was created during the Debian installation# (network, broadcast and gateway are optional)auto eth0iface eth0 inet static#set your static IP belowaddress 192.168.1.118#set your default gateway IP heregateway 192.168.1.1netmask 255.255.255.0network 192.168.1.0broadcast 192.168.1.255
- Now, restart your networking setting using the command below
1$ /etc/init.d/networking restart
- Once restarted, your Debian will run on new IP. If you are using SSH to configure the above settings, you will get disconnected. No worry, you can now reconnect to Debian using new the IP.
- Done, you have just configure your Debian to run on static IP.