Created
December 7, 2017 06:58
-
-
Save maxguru/5ae1f74ec7b33d747a2d8b8687d21e0e to your computer and use it in GitHub Desktop.
Script that sets up a different default route for all processes of a particular user on the system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OTHER_IFACE="eth1" | |
OTHER_GW="10.0.3.2" | |
USER="xyz" | |
ip rule add fwmark 35 table 35 | |
ip route add default via $OTHER_GW dev $OTHER_IFACE table 35 | |
ip route flush cache | |
iptables -t mangle -A OUTPUT -m owner --uid-owner $USER -j MARK --set-mark 35 | |
iptables -t nat -A POSTROUTING -o $OTHER_IFACE -m mark --mark 35 -j MASQUERADE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires the following on OpenWrt/LEDE,
Module for
-m owner
For adding a user and running as one,