ubuntu static ip configuration

Linux Basics - Set A Static IP On CentOS/ Ubuntu


This tutorial explains how to set a static IP on an Ubuntu system from the command line.
Static IP configuration on RHEL/centos(working config)
=========================================
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
HWADDR=00:0c:29:07:74:eb
TYPE=Ethernet

BOOTPROTO=none
IPADDR=192.168.213.10
NETMASK=255.255.255.0
GATEWAY=192.168.213.2
NM_CONTROLLED=no
DNS1=8.8.8.8
USERCTL=no
IPV6INIT=no

Step 1

You can copy and paste directly from this line.
sudo nano /etc/network/interfaces

If you have more than one network card, please be sure to make changes to the correct network interface.
Statically configured network cards will have a section like:

Here is an example:
auto lo eth0
iface lo inet loopback
iface eth0 inet static   #dynamic for dhcp
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4

#dns ns ip changed here will have corresponding change in /etc/resolv.conf 

cat /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8
nameserver 8.8.4.4
 resolvconf -u

=>if not seen change on /etc/resolv.conf   edit that file and add
nameserver 8.8.8.8
nameserver 8.8.4.4
 save/exit

you can change with chattr +i /etc/resolv.conf
#service networking restart
or
#ifdown eth0
#ifup eth0

No comments:

Post a Comment