diff --git a/How-to-use-glorytun-with-2-isp-(draft).md b/How-to-use-glorytun-with-2-isp-(draft).md index ba07fa5..d7df854 100644 --- a/How-to-use-glorytun-with-2-isp-(draft).md +++ b/How-to-use-glorytun-with-2-isp-(draft).md @@ -72,4 +72,105 @@ iptables -I FORWARD -i tun0 -o eth0 -j ACCEPT ## **Client side:** +Now, we need to configure Ubuntu OS to using 2 ISP, for this we turn to LARTC (Linux Advanced Routing & Traffic Control), there are many different articles on this topic on the Internet, i will give one worked example of this configuration + +1) edit file **/etc/iproute2/rt_tables** and adding two lines about our 2 ISP in system route table, +you may use pre-installed in Ubuntu **nano editor** for edit files, with this command: + +`nano /etc/iproute2/rt_tables` + +``` +# +# reserved values +# +#255 local +#254 main +#253 default +#0 unspec +101 isp1 #<---------add this string to file rt_tables +102 isp2 #<---------add this string to file rt_tables +``` +after edit, for save file press keyboard shortcut **Ctrl+O**, and **Ctrl+X** for exit, it's simple! + + +2) create this script for builds a traffic routing table: + +`nano /root/dual_isp.sh` + +note: you may copy & paste this script with Bitvise SSH Client from Windows OS to Ubuntu OS, directly in Nano editor window + +``` +#script path: /root/dual_isp.sh +#script for dual isp connection (linux, ubuntu, debian) +#!/bin/sh +#!/bin/bash + +# LAN interface +IF0="enp2s0" + +# ISP interface 1 +IF1="enp6s0" +# ISP interface 2 +IF2="enp6s1" + +# IPv4 addresses from ISP interfaces, IP1 for ISP1(IF1) and IP2 for ISP2(IF2), offered by DHCP from isp routers.. +IP1="192.168.1.100" +IP2="192.168.2.100" + +# gateway 1 of ISP1(IF1) +P1="192.168.1.1" +# gateway 2 of ISP2(IF2) +P2="192.168.2.1" + +# LAN netmask of LAN +P0_NET="10.10.10.0/24" +# WAN1 netmask of ISP1(IF1) +P1_NET="192.168.1.0/24" +# WAN2 netmask of ISP2(IF2) +P2_NET="192.168.2.0/24" + +#this settings from /etc/iproute2/rt_tables file +TBL1="isp1" +TBL2="isp2" + +#also i recommend permanently enable ip v4 forwarding with edit file /etc/sysctl.conf +echo "1" > /proc/sys/net/ipv4/ip_forward + +ip route add $P1_NET dev $IF1 src $IP1 table $TBL1 > /dev/null 2>&1 +ip route add default via $P1 table $TBL1 > /dev/null 2>&1 +ip route add $P2_NET dev $IF2 src $IP2 table $TBL2 > /dev/null 2>&1 +ip route add default via $P2 table $TBL2 > /dev/null 2>&1 + +ip route add $P1_NET dev $IF1 src $IP1 > /dev/null 2>&1 +ip route add $P2_NET dev $IF2 src $IP2 + +#adding default gateway only with ISP1 and it's normal.. +ip route add default via $P1 > /dev/null 2>&1 + +ip rule add from $IP1 table $TBL1 > /dev/null 2>&1 +ip rule add from $IP2 table $TBL2 > /dev/null 2>&1 + +ip route add $P0_NET dev $IF0 table $TBL1 > /dev/null 2>&1 +ip route add $P2_NET dev $IF2 table $TBL1 > /dev/null 2>&1 +ip route add 127.0.0.0/8 dev lo table $TBL1 > /dev/null 2>&1 +ip route add $P0_NET dev $IF0 table $TBL2 > /dev/null 2>&1 +ip route add $P1_NET dev $IF1 table $TBL2 > /dev/null 2>&1 +ip route add 127.0.0.0/8 dev lo table $TBL2 > /dev/null 2>&1 + +#masqarade local (lan) traffic to both isp, iptables rules +iptables -t nat -F POSTROUTING +iptables -t nat -A POSTROUTING -s $P0_NET -o $IF1 -j MASQUERADE +iptables -t nat -A POSTROUTING -s $P0_NET -o $IF2 -j MASQUERADE +``` + +after edit, for save file press keyboard shortcut **Ctrl+O**, and **Ctrl+X** for exit + +then make our script executable: +`chmod +x dual_isp.sh` + +and run it with this command: +`./dual_isp.sh` + +**at this stage, we have completed the preparation Ubuntu OS on the client and proceed to install and configure Glorytun** + # ### soon \ No newline at end of file