Here we shall take www as the service for routing. Use mangle table of iptable for modifying the www packets.
sudo iptables -t mangle -A OUTPUT -p tcp --dport 80 -j MARK --set-mark 0x1
We are marking all packets with destination port 80 as 0x1 .
Now save and restart iptables.
service iptables save
service iptables restart
Next, create a new IP route table in /etc/iproute2/rt_tables by just giving an entry
100 wwwtable
Write rule for www packets.
ip rule add fwmark 0x1 lookup wwwtable
Add route at new table wwwtable. All other traffic will go through the
default gateway, which can be seen by ip route show command.
We copy all entries except default gateway entry from main table.
sudo ip route show table main | grep -Ev ^default | while read ROUTE ; do ip route add table wwwtable $ROUTE; done
Add default gateway entry for www packets to table wwwtable
sudo ip route add default dev ppp0 table wwwtable
Use ip route show table wwwtable to show all routes at wwwtable.
Repeat everything for https on port 443.