ginuerzh / gost

GO Simple Tunnel - a simple tunnel written in golang
MIT License
15.57k stars 2.44k forks source link

Add -M option for Fwmark #746

Closed purerosefallen closed 2 years ago

purerosefallen commented 2 years ago

Added an -M <mark> option to specify fwmark for outbound connections. It can also be set by config file.

{
    "Routes": [
        {
            "Retries": 3,
            "ServeNodes": [
                "quic://:443"
            ],
            "Mark": 1000
        }
    ]
}
ginuerzh commented 2 years ago

Could you explain the function of this option?

purerosefallen commented 2 years ago

To specify the outgoing connection's mark, used by iptables or iproute2. This is to make more custom routing rules. A quick example could be, after setting mark to 1000, we can set the following rule, making all outgoing traffic from a specific route of gost going to a specific gateway.

ip route add default via ppp1 table 1000
ip rule add pref 100 fwmark 1000 lookup 1000