Jump to: navigation, search

Setup Static IP Address in Ubuntu Linux

From w3cyberlearnings

Contents

Setup static IP address in Ubuntu Linux

  • Require to have a root or super user privilege
  • A static IP Address to be used or assigned
  • List of a network information:Gateway, DNS Server, Server IP address
  • Have a good understanding in VIM/VI or any other text editors and Linux command line

Get Information about the current OS

Get IP Address of the current HOST so that we can use the IP to make the static configuration. If you have already had the static IP address provided by your ISP or administrator. You can skip this section.

sophal@sophal-desktop:~$ ifconfig -a
eth4      Link encap:Ethernet  HWaddr 00:0c:29:a3:78:c8  
          inet addr:192.168.244.129  Bcast:192.168.244.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea3:78c8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:153 errors:0 dropped:0 overruns:0 frame:0
          TX packets:204 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:15449 (15.0 KB)  TX bytes:18494 (18.0 KB)
          Interrupt:18 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:224 errors:0 dropped:0 overruns:0 frame:0
          TX packets:224 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:11200 (10.9 KB)  TX bytes:11200 (10.9 KB)

Display Routing Table

Get Network Information.

sophal@sophal-desktop:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.244.0   0.0.0.0         255.255.255.0   U     0      0        0 eth4
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth4
0.0.0.0         192.168.244.2   0.0.0.0         UG    0      0        0 eth4

Get Network Information

List the network information that use for the configuration.

Host IP address 192.168.244.129
Netmask: 255.255.255.0
Network ID: 192.168.244.0
Broadcast IP: 192.168.244.255
Gateway/Router IP: 192.168.244.2
DNS Server: 192.168.244.2

Edit /etc/network/interfaces file

Add the network configuration information to the interfaces file to setup the static IP address.

iface eth0 inet static
address 192.168.244.129
netmask 255.255.255.0
network 192.168.244.0
broadcast 192.168.244.255
gateway 192.168.244.2

Restart your network

root@sophal-desktop:/home/sophal# /etc/init.d/networking restart
 * Reconfiguring network interfaces...            

Edit /etc/resolv.conf

Add DNS Server, if you have more than one DNS server

  • nameserver 192.158.333.3
search localdomain
nameserver 192.168.244.2

Test the static IP address

  • If you can ping to any website or domain name within your network, it means you can connect to the internet.
$ping google.com
Navigation
Web
SQL
MISC
References