Saturday, May 2, 2009

How to set a static IP in Ubuntu from the shellHow to set a static IP in Ubuntu from the shell

Kepada sesapa yang tak mau guna dhcp dalam ubuntu, bolehla set statik ip. Caranya agak kacang.

Mula-mula bukak terminal:
Applications > Accessories > Terminal

Taip @ copy & paste command di bawah:

sudo vi /etc/network/interface
Adjust mengikut citarasa masing-masing. Dalam contoh di bawah guna 192.168.0.100
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
script grep
map eth0

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
Lepas tu tekan kekunci "Esc"
Kemudian taip ":wq" > enter (write/ save/ quit )

Untuk restart servis networking, run command ni

sudo /etc/init.d/networking restart

No comments: