This post covers configuration changes required to set a static IP address on a server / desktop.
First get information about all the interfaces in the system with the command ifconfig -a .
Network configuration. Assign an address, netmask, gateway and DNS for an ethernet interface in the /etc/network/interfaces files (Debian or Ubuntu).
Edit the file using nano /etc/network/interfaces and add the following information:
- address 192.168.0.10
- netmask 255.255.255.0
- gateway 192.168.0.1
- dns-nameservers 192.168.0.1 188.8.131.52
The above is for an internal network. If your server is connected directly to the internet you need to use a public address and gateway. If you don’t have these details consult with your server supplier.
Apply the changes using the command ifdown etho; ifup eth0 , keep in mind you will lose your SSH connection at this point. Re-connect using the new IP address. Alternatively restart the networking with /etc/init.d/networking restart .
If you get errors connecting, check if a wire is connected with grep “” eth0/*
cd /sys/class/net grep "" eth0/operstate grep "" eth1/operstate grep "" eth0/carrier grep "" eth1/carrier
When the wire is plugged in:
if the wire is removed