Rolly Maulana Awangga :: Catatan Ngoprek IT

Pakar dan Awam sama saja, sama sama belajar

Load Balancing Internet Conection

Rules Table

 

Here some command to get load balancing server as a router two, by joining two interface with internet connection based on this article.

ip link set lo up
ip link set eth0 up
ip link set eth0:0 up
#ip link set usb0 up
ip route flush table rt_dev1
ip route flush table rt_dev2
ip route flush table internet

ip addr add 127.0.0.1/8 brd 127.0.0.255 dev lo
ip addr add 192.168.42.83/24 brd 192.168.42.255 dev usb0
ip addr add 192.168.1.1/24 brd 192.168.1.255 dev eth0
ip addr add 192.168.1.2/24 brd 192.168.1.255 dev eth0:0

ip rule add prio 10 table main
ip rule add prio 20 table rt_dev1
ip rule add prio 30 table rt_dev2
ip rule add prio 40 table internet

ip route del default table main
ip route del default table rt_dev1
ip route del default table rt_dev2
ip route del default table internet

ip rule add prio 20 from 192.168.42.0/24 table rt_dev1
ip route add default via 192.168.42.129 dev usb0 src 192.168.42.83 proto static table rt_dev1
ip route append prohibit default table rt_dev1 metric 1 proto static

ip rule add prio 30 from 192.168.1.0/24 table rt_dev2
ip route add default via 192.168.1.3 dev eth0:0 src 192.168.1.2 proto static table rt_dev2
ip route append prohibit default table rt_dev2 metric 5 proto static

ip rule add prio 40 table internet
ip route add default proto static table internet nexthop via 192.168.42.129 dev usb0 weight 1 nexthop via 192.168.1.3 dev eth0:0 weight 1

iptables -F
iptables -P INPUT DROP
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -i usb0 -p tcp -s 0/0 –dport 25 -j ACCEPT
iptables -A INPUT -i eth0:0 -p tcp -s 0/0 –dport 25 -j ACCEPT
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -i usb0 -j REJECT –reject-with tcp-reset
iptables -A INPUT -p tcp -i eth0:0 -j REJECT –reject-with tcp-reset
iptables -A INPUT -p udp -i usb0 -j REJECT –reject-with icmp-port-unreachable
iptables -A INPUT -p udp -i eth0:0 -j REJECT –reject-with icmp-port-unreachable
iptables -t nat -A POSTROUTING -o eth0:0 -j SNAT –to-source 192.168.1.2
iptables -t nat -A POSTROUTING -o usb0 -j SNAT –to-source 192.168.42.83

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: