setting ubuntu sebagai gateway :
================================
contoh :
Ip ubuntu ke modem (eth0) : 192.168.1.253/24
Gateway (ip modem) : 192.168.1.1
IP ubuntu ke lan (eth1):192.168.45.1/24
Langkah utama ada 4 yaitu :
=================================
1. Seting IP di eth0 dan eth1
=================================
pico /etc/network/interfaces
=================================
# 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
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.253
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8 8.8.4.4
auto eth1
iface eth1 inet static
address 192.168.45.1
netmask 255.255.255.0
=================================
simpan konfigurasi dan keluar, lalu restart menggunakan perintah :
/etc/init.d/networking restart
=================================
=================================
2. seting IP Forwarding
=================================
pico /etc/rc.local
tambahkan rules berikut sebelum exit 0 :
echo 1 > /proc/sys/net/ipv4/ip_forward
lalu simpan perubahannya.
=================================
pico /etc/sysctl.conf
=================================
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
ketikkan perintah :
sysctl -p
apabila reportnya :
net.ipv4.ip_forward=1
berarti ip forwarding sudah aktif.
=================================
=================================
3. Membuat iptables
=================================
pico /etc/rc.local
sesudah rule :
echo 1 > /proc/sys/net/ipv4/ip_forward
tambahkan rule berikut :
iptables –t nat –A POSTROUTING –j MASQUERADE
jika menggunakan squid/lusca sebagai proxy, tambahkan rule berikut (sesuaikan dengan konfigurasi port dalam squid.conf :
iptables –t nat –A PREROUTING –p tcp –dport 80 –j REDIRECT –to-port 3128
jika proxy yang digunakan mendukung ssl bump untuk cache https, tambahkan rule berikut (sesuaikan dengan konfigurasi port dalam squid.conf :
iptables –t nat –A PREROUTING –p tcp –dport 443 –j REDIRECT –to-port 3127
lalu simpan perubahannya.
aktifkan rc.local dengan mengetikkan perintah :
/etc/init.d/rc.local start
=================================
=================================
4. Testing di client
=================================
Setting IP di salah satu client dengan konfigurasi berikut :
ip : 192.168.45.2
netmask : 255.255.255.0
gateway : 192.168.45.1
DNS : 8.8.8.8 8.8.4.4
tes ping pada cmd
ping 8.8.8.8
Jika reply saat ping, maka seting gateway sudah ok.
Jika belum? tanya forum atau teman yang lebih tahu 🙂
mungkin dapat di implementasikan pada router mikrotik sebagai client dari gateway ubuntu server
Komentar Terakhir