How to Set Static IP Address on Ubuntu 14


For your information, by default the Ubuntu 14 sets the interface to use DHCP. And here’s how to set a static IP address on ubuntu 14.
To change static IP through terminal,  you have to Edit this configuration -> /etc/network/interfaces.  In this example use 192.168.1.? (? = your absen number + 10) as our server IP address.

Now go to the TERMINAL, write this command:
farihin@farihin-virtual-machine:~$ sudo su
[sudo] password for farihin:
====================================
root@farihin-virtual-machine:/home/farihin# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:20:25:a9
inet6 addr: fe80::20c:29ff:fe20:25a9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:270 errors:0 dropped:0 overruns:0 frame:0
TX packets:126 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16488 (16.4 KB) TX bytes:24569 (24.5 KB)
Interrupt:19 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:65536 Metric:1
RX packets:153 errors:0 dropped:0 overruns:0 frame:0
TX packets:153 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:11454 (11.4 KB) TX bytes:11454 (11.4 KB)
===================================
root@farihin-virtual-machine:/home/farihin# sudo nano /etc/network/interfaces
=================================================
GNU nano 2.2.6 File: /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
==================================
GNU nano 2.2.6 File: /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
#auto lo
#iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.40
netmask 255.255.255.0
network 192.168.1.1
=======================================
note: press CTRl and X, then type Y, then press ENTER
=======================================
root@farihin-virtual-machine:/home/farihin# sudo ifdown eth0 && sudo ifup eth0
note: if needed (in case error appear) you can then type-> sudo service network-manager restart -> then run ifdown command once more. If that’s not help reboot your ubuntu machine.
=====================================
root@farihin-virtual-machine:/home/farihin# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0c:29:20:25:a9
inet addr:192.168.1.40 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe20:25a9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2172 errors:0 dropped:0 overruns:0 frame:0
TX packets:1625 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:157382 (157.3 KB) TX bytes:281327 (281.3 KB)
Interrupt:19 Base address:0x2000
========================================
root@farihin-virtual-machine:/home/farihin# ping 192.168.1.40
PING 192.168.1.40 (192.168.1.40) 56(84) bytes of data.
64 bytes from 192.168.1.40: icmp_seq=1 ttl=64 time=0.058 ms
64 bytes from 192.168.1.40: icmp_seq=2 ttl=64 time=0.058 ms
64 bytes from 192.168.1.40: icmp_seq=3 ttl=64 time=0.053 ms
64 bytes from 192.168.1.40: icmp_seq=4 ttl=64 time=0.052 ms
64 bytes from 192.168.1.40: icmp_seq=5 ttl=64 time=0.047 ms
64 bytes from 192.168.1.40: icmp_seq=6 ttl=64 time=0.052 ms
^C
--- 192.168.1.40 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5000ms
rtt min/avg/max/mdev = 0.047/0.053/0.058/0.007 ms
root@farihin-virtual-machine:/home/farihin#

Post a Comment

Previous Post Next Post