Today I wanted to set up my Linux box so that it had a static ip address for shared resources like Samba.
The network card that I happen to be using for it was eth0. If you are using a different one then you may need to modify the code below to match the eth* that you are using.
Here are the steps that I took to accomplish this:
1. I edited the /etc/network/interfaces file with:
-
sudo nano /etc/network/interfaces
2. I added the following lines:
-
auto eth0
-
iface etho inet static
-
address 192.168.1.2
-
netmask 255.255.255.0
-
gateway 192.168.1.1
3. I restarted networking on the box and all was good.
sudo /etc/init.d/networking restart
Pay close attention to the netmask and the gateway. If these are different you will need to make adjustments as needed. I found these in my routers web gui.
My completed /etc/network/interfaces now looks like:
-
auto lo
-
iface lo inet loopback
-
-
auto eth0
-
iface etho inet static
-
address 192.168.1.2
-
netmask 255.255.255.0
-
gateway 192.168.1.1
