Tuesday, December 20, 2011

Linux Static IP

Debian Like Linux

vi /etc/network/interfaces

auto eth0
#iface eth0 inet dhcp # -> changed to static

iface eth0 inet static

# and add IP address information

address 10.1.1.*
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
gateway 10.1.1.*(your gateway address)

:wq!

# service networking restart

Finished

Redhat like

vi /etc/sysconfig/network-script/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
BROADCAST=10.10.10.255
HWADDR=AA:FF:00:**:**:**
IPADDR=10.10.10.** -> your IP address
IPV6INIT=yes -> up to you
IPV6_AUTOCONF=yes -> up to you
NETMASK=255.255.255.0
NETWORK=10.10.10.0
ONBOOT=yes

:wq!

/etc/init.d/network restart

Add default gateway

route add default gw 10.10.10.***

Finished

add DNS

vi /etc/resolv.conf

nameserver 8.8.8.8
nameserver 203.12.160.35

:wq!

try nslookup or ping google.com

Finished