static IP in debian

Red Squirrel

No Lifer
May 24, 2003
70,174
13,575
126
www.anyf.ca
I want to setup my debian machine (on a network) to have a static IP. In RH I had to edit /etc/sysconfig/network-scripts/ifcfg-eth0 and put
Code:
DEVICE=eth0
BOOTPROTO=static
onBOOT=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
but can't seem to find that file in debian. Well if I type locate ifcfg-eth0 it shows up but if I try to cd to it, it just says no file found or whatever.

So what is the equivalent of that in debian? Also is there a command I have to do with ifconfig to apply it? Last time I did this was a long time so I may be missing something here. But I think I remember just having to edit that file and I was good to go.

I also found a tutorial that says it's /etc/init.d/network but there's no file there, and for fun tried to create it but it did not do anything.


I keep finding lot of forums where this question was asked but it was never answered. But I did find a tutorial and it said something about it being worked on, so does it mean it's impossible to set a static IP in debian yet? I sure hope not since it will make it living hell since it will be acting as a DNS server along with many other things.

Also lot of debian tutorials keep poiting to /etc/sysconfig/networking, but why? that does not exist under debian. The whole /etc/sysconfig is non existant. Have no clue where those files are and what they're called.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Debian has a different setup. It's in the interfaces file in the /etc/network directory.

Here is a mine:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0

iface eth0 inet static
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.254


There are some docs online and their are the man files. And there are some examples in:
/usr/share/doc/ifupdown/examples

you edit the file, do 'ifdown eth0' then 'ifup eth0' then sometimes you have to kill dchcpd or dclient so that it doesn't reconfigure your interface (temporarially) when your dhcp lease runs out.