Recipes » Static IP

Static IP

Last modified by Administrator on 2011/06/06 17:26

Static IP

Linux en

  1. In a single shell session:
    ifconfig eth0 10.100.29.91 netmask 255.255.255.0
    Or two separate commands:
    ifconfig eth0 10.100.29.91
    ifconfig eth0 netmask 255.255.255.0
  2. Define gateway:
    route add default gw 10.0.0.1

Configuring IP address permanently

  1. edit /etc/network/interfaces, do not touch "lo" (loopback interface is usually configured correctly), and add these lines:
    auto eth0
    iface eth0 inet static
         address 10.120.29.91
         network 10.120.29.0
         netmask 255.255.255.0
         broadcast 10.120.29.255
         gateway 10.120.29.1
  2. Extra address is configured as follows:
    auto eth0:1
    iface eth0:1 inet static
         address 10.120.29.92
         network 10.120.29.0
         netmask 255.255.255.0
         broadcast 10.120.29.255
  3. DHCP address is configured as follows (assume that "eth1" is another network card):
    auto eth1
    iface eth1 inet dhcp

Restarting network configuration

  1. To make the configuration active, restart the network settings:
    /etc/init.d/networking restart
    1. To perform this service always during boot, it can be added to the startup services:
      update-rc.d script_name defaults

Checking network settings

  1. IP address/mask, the DNS servers and the gateway are checked by these commands:
    ifconfig -a
    more /etc/resolv.conf
    ip route
  2. The resolv.conf could contain DNS servers in their search order. E.g.
    nameserver 10.120.4.50
    nameserver 10.120.4.51
    nameserver 10.2.2.75
    nameserver 10.2.2.101

Links

  1. http://odo.lv/Recipes/StaticIP

Tags:  

Tags:
Created by Kalvis Apsītis on 2009/08/03 11:19

This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 3.0.36132 - Documentation