#!/bin/bash
interface=$1
event=$2
if [[ "$interface" == "enp6s0f0" && "$event" == "up" ]]; then
ip route add default via 192.168.3.254 table second
ip rule add from 192.168.3.0/24 table second
fi
然後要記得把這個檔案 chmod 755 讓他可以執行。
接著是 Squid 的設定,在 /etc/squid/squid.conf 裡面這樣寫:
#
http_access allow all
#
access_log /var/log/squid/access.log squid
cache deny all
cache_dir null /tmp
cache_log /dev/null
cache_mem 8 MB
dns_v4_first on
forwarded_for off
http_port 3128
tcp_outgoing_address 192.168.3.x
其中最後的 192.168.3.x 換成自己的固定 IP address。這邊因為 traffic 基本上都是 HTTPS 了,也不需要開 cache,就這樣設定...