Friday, March 2, 2012

Pengaturan IP Address pada Linux

Tulisan ini merupakan suatu hal yang sangat umum bagi anda, namun sangat bermanfaat bagi saya sendiri (lihat juga [Linux] Mengenal Linux Command Line ), kenapa demikian, karena dalam jaringan komputer sangat "wajib" mengetahui bagaimana cara merubah suatu alamat ip yang merupakan identitas untuk sebuah host dalam jaringan komputer agar bisa mengenali host masing - masing yang terhubung.

Perbedaan yang sangat berarti dalam sistem operasi linux, yang notabene sistem operasi yang powerfull untuk segi kebutuhan server, dengan tingkat keamanan yang tinggi dan lebih banyak kegunaan yang ada jika kita menggunakan atau mengimplementasikan kedalam infrastruktur jaringan kita.
Bagaimana melihat interface jaringan komputer yang ada ?

dasar dari command line yang ada dalam linux terutama untuk distro linux turunan redhat/fedora/centos serta ubuntu dan turunannya

triwanda@ubuntu:~$ ifconfig

maka  untuk hasilnya dapat dilihat interface yang aktif dalam komputer.

eth0      Link encap:Ethernet  HWaddr 00:26:2d:a7:1a:13
UP BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Interrupt:16

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:9879 errors:0 dropped:0 overruns:0 frame:0
TX packets:9879 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:8072293 (8.0 MB)  TX bytes:8072293 (8.0 MB)

ppp0      Link encap:Point-to-Point Protocol
inet addr:10.1x9.1xx.1xx  P-t-P:10.17.95.18  Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
RX packets:28101 errors:1 dropped:0 overruns:0 frame:0
TX packets:29782 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:23204534 (23.2 MB)  TX bytes:3661346 (3.6 MB)

wlan0     Link encap:Ethernet  HWaddr 78:e4:00:a2:86:55
UP BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

jika ingin menampilkan satu interface saja, misalkan eth0, maka cukup dengan

triwanda@ubuntu:~$ ifconfig eth0

Bagaimana mengganti alamat IP ?
Oke, pada sistem operasi turunan Debian/Ubuntu dan RedHat/fedora memiliki perbedaan
  • Untuk melihat alamat IP pada setiap interface dengan command
Ubuntu

triwanda@ubuntu:~$ cat /etc/network/interfaces

maka akan terlihat interface atau perangkat jaringannya

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

#auto eth0
#iface eth0 inet static
#    address 192.168.56.1
#    netmask 255.255.255.0
#    network 192.168.56.0
#    broadcast 192.168.56.255

auto eth1
iface eth1 inet dhcp

auto eth2
iface eth2 inet dhcp

auto ath0
iface ath0 inet dhcp

auto wlan0
iface wlan0 inet dhcp

CentOS

Pada sistem operasi ini agak sedikit berbeda dengan memakai OS CentOS 5.7 ada di direktori  /etc/sysconfig/network-scripts/

[root@localhost ~]# cd /etc/sysconfig/network-scripts/

maka akan terlihat seperti

[root@localhost network-scripts]# ls -l
total 388
-rw-r--r-- 1 root root   163 Mar  1 16:24 ifcfg-eth0
-rw-r--r-- 2 root root   119 Oct 11 19:58 ifcfg-eth0.bak
-rw-r--r-- 1 root root   254 Jun  8  2011 ifcfg-lo
lrwxrwxrwx 1 root root    20 Oct 11 20:01 ifdown -> ../../../sbin/ifdown
-rwxr-xr-x 1 root root   625 Jun  8  2011 ifdown-bnep
-rwxr-xr-x 1 root root  5336 Jun  8  2011 ifdown-eth
-rwxr-xr-x 1 root root   827 Jun  8  2011 ifdown-ippp
-rwxr-xr-x 1 root root  2149 Jun  8  2011 ifdown-ipsec
-rwxr-xr-x 1 root root  4396 Jun  8  2011 ifdown-ipv6
lrwxrwxrwx 1 root root    11 Oct 11 20:01 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x 1 root root  1481 Jun  8  2011 ifdown-post
-rwxr-xr-x 1 root root  1084 Jun  8  2011 ifdown-ppp
-rwxr-xr-x 1 root root   637 Jun  8  2011 ifdown-routes
-rwxr-xr-x 1 root root  1596 Jun  8  2011 ifdown-sit
-rwxr-xr-x 1 root root   913 Jun  8  2011 ifdown-sl
-rwxr-xr-x 1 root root  1077 Jun  8  2011 ifdown-tunnel
lrwxrwxrwx 1 root root    18 Oct 11 20:01 ifup -> ../../../sbin/ifup
-rwxr-xr-x 1 root root 13422 Jun  8  2011 ifup-aliases
-rwxr-xr-x 1 root root   859 Jun  8  2011 ifup-bnep
-rwxr-xr-x 1 root root 10984 Jun  8  2011 ifup-eth
-rwxr-xr-x 1 root root 12033 Jun  8  2011 ifup-ippp
-rwxr-xr-x 1 root root  8078 Jun  8  2011 ifup-ipsec
-rwxr-xr-x 1 root root 10858 Jun  8  2011 ifup-ipv6
-rwxr-xr-x 1 root root   823 Jun  8  2011 ifup-ipx
lrwxrwxrwx 1 root root     9 Oct 11 20:01 ifup-isdn -> ifup-ippp
-rwxr-xr-x 1 root root   727 Jun  8  2011 ifup-plip
-rwxr-xr-x 1 root root   954 Jun  8  2011 ifup-plusb
-rwxr-xr-x 1 root root  2369 Jun  8  2011 ifup-post
-rwxr-xr-x 1 root root  4298 Jun  8  2011 ifup-ppp
-rwxr-xr-x 1 root root  1707 Jun  8  2011 ifup-routes
-rwxr-xr-x 1 root root  3671 Jun  8  2011 ifup-sit
-rwxr-xr-x 1 root root  1675 Jun  8  2011 ifup-sl
-rwxr-xr-x 1 root root  2084 Jun  8  2011 ifup-tunnel
-rwxr-xr-x 1 root root  3325 Jun  8  2011 ifup-wireless
-rwxr-xr-x 1 root root  5433 Jun  8  2011 init.ipv6-global
-rwxr-xr-x 1 root root  1154 Jun  8  2011 net.hotplug
-rw-r--r-- 1 root root 10915 Jun  8  2011 network-functions
-rw-r--r-- 1 root root 39863 Jun  8  2011 network-functions-ipv6

untuk mengubah alamat ip, misalkan ifcfg-eth0 secara manual ketika sudah masuk kedalam direktori ini maka akan terlihat seperti

# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.56.5
NETMASK=255.255.255.0
ONBOOT=yes
HWADDR=08:00:27:f0:2b:01

ubahlah alamat ip pada IPADDR dan NETMASK-nya

Proses Akhir

Untuk proses akhir padaUbuntu dan CentOSdengan menyimpan pengaturan tidak jauh berbeda.

Ubuntu

triwanda@ubuntu:~$ sudo /etc/init.d/networking start

CentOS

[root@localhost network-scripts]#  /etc/init.d/network start

dengan direstart kembali network yang sudah diubah sebelumnya, maka pengaturan yang sebelumnya akan terganti oleh pengaturan yang baru.

No comments:

Post a Comment