Switching from dynamic IP to static IP 

Synopsis 

*Tags*: Switching from dynamic to static IP for Debian network

edit

/etc/network/interfaces

then

/etc/init.d/networking restart

Switching from dynamic IP to static IP 

Newsgroups:  gmane.linux.debian.user
Date:        Wed, 16 Feb 2005 11:57:05 -0500

My IP get changed by my router from time to time, and there is no way to assign a fixed IP from the router side.

So I need to switch from dhcp to static IP.

I've done that in RH before. Basically, I only need to change the following two files:

/etc/sysconfig/network:
NETWORKING=yes
HOSTNAME=xpt
GATEWAY=192.168.0.1
/etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
ONBOOT=yes

However, I found that the file /etc/sysconfig/network does not exist in Debian. What files should I change in Debian? Thanks.

Switching from dynamic IP to static IP 

> Debian. What files should I change in Debian? Thanks.

The 'Debian Way' to do this doesn't involve editing files directly.

Install the program etherconf (or use dpkg-reconfigure etherconf if you already have it) and it will ask you questions about your IP setup (DHCP, or static, gateways DNS etc.) and write out the appropriate files for you.

Dave Ewart

Switching from dynamic IP to static IP 

> I've done that in RH before. Basically, I only need to change the
> following two files: [...]

Just one in Debian: /etc/network/interfaces (assuming your nic is not pcmcia).

Jacob S

Switching from dynamic IP to static IP 

/etc/network/interfaces

change 'dhcp' to 'static'

then add

address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx

Matt Johnson

Switching from dynamic IP to static IP 

> So I need to switch from dhcp to static IP.

edit /etc/network/interfaces

change

auto eth0
iface eth0 inet dhcp

to

auto eth0
iface eth0 inet static
        address 192.168.0.100
        network 192.168.0.0
        netmask 255.255.255.0
        gateway 192.168.0.1
        broadcast 192.168.0.255

Matt Zagrabelny