Thursday, December 25, 2014

Share Koneksi Internet di Ubuntu

catatan : Tutorial ini hanya berlaku di Ubuntu 14.04

Koneksi internet di laptop (konek kabel LAN) akan dishare melalui wifi (laptop dijadikan access point).

1. Install dhcp3-server dan hostapd
sudo apt-get install dhcp3-server hostapd

2. Edit file /etc/hostapd/hostapd.conf
sudo [text_editor] /etc/hostapd/hostapd.conf

ganti [text_editor] dengan nama program text editor di Ubuntu, misalnya gedit

*gedit adalah program text editor semacam notepad, belum terinstall secara default di Lubuntu. Bisa install dulu geditnya atau pakai program lain semisal leafpad yang sudah ada otomatis di Lubuntu, perintah di Lubuntu menjadi
sudo leafpad /etc/hostapd/hostapd.conf
Selanjutnya isi file /etc/hostapd/hostapd.conf seperti berikut
interface=wlan0
driver=nl80211
ssid=geekpeek
channel=1
hw_mode=g
auth_algs=1
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP

keterangan
geekpeek --> nama wifi
12345678 --> password wifi

Ubah nama wifi dan password wifi sesuai kebutuhan kamu, simpan file.

3. Edit file /etc/default/isc-dhcp-server
sudo [text_editor] /etc/default/isc-dhcp-server

ubah
INTERFACES=""
menjadi
INTERFACES="wlan0"

simpan file

4. Edit file /etc/dhcp/dhcpd.conf
sudo [text_editor] /etc/dhcp/dhcpd.conf

tambahkan di akhir file seperti berikut
subnet 10.10.0.0 netmask 255.255.255.0 {
        range 10.10.0.2 10.10.0.16;
        option domain-name-servers 8.8.4.4, 8.8.8.8;
        option routers 10.10.0.1;
}

simpan file

5. Edit file /etc/sysctl.conf
hilangkan tanda # di depan baris
awalnya
#net.ipv4.ip_forward = 1

ubah menjadi
net.ipv4.ip_forward = 1

6. Buat script bash, beri nama sesuka kamu. Misalnya ini saya buat file Documents/wifi.sh (file bernama wifi.sh, tersimpan di folder Documents pada directory home user linux), isi file sebagai berikut
#!/bin/bash
nmcli nm wifi off
rfkill unblock wlan
ifconfig wlan0 10.10.0.1/24
iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o eth0 -j MASQUERADE
service isc-dhcp-server start
hostapd /etc/hostapd/hostapd.conf

Buatnya pakai text editor yah (gedit, leafpad, nano, dll). Simpan kalau sudah.

Beri akses execute ke file
chmod +x Documents/wifi.sh

Restart laptop

Untuk menjalankan tethering, ini perintahnya
sudo ~/Documents/wifi.sh

Untuk mematikan tethering, tekan Ctrl+C pada terminal yang menjalankan script bash tadi

Sumber
http://thebeautifullmind.com/2012/09/19/sharing-internet-over-wifi-between-ubuntu-and-android/

Lazada Indonesia

2 comments:

Unknown said...

chmod: changing permissions of ‘Documents/kucur.sh’: Operation not permitted

solusi gan? #newbie

ardhi wijayanto said...

mungkin karena kamu create filenya sebagai root, coba sebelum printah chmod kamu tambahkan sudo, misalnya : sudo chmod +x nama_file.sh

Post a Comment

ardhi.web.id. Powered by Blogger.