ubuntu 桌面版設(shè)置好RedSocks翻墻后,作為NAT路由配置

sysctl -w net.ipv4.conf.eth0.route_localnet=1

By default this value is 0, which instructs the kernel to not route external traffic destined to 127.0.0.0/8. This is just for security as such traffic is not normal.

iptables -t nat -I PREROUTING -p udp -d 192.168.170.0/24 --dport 53 -j DNAT --to-destination 127.0.1.1:53

vi /etc/sysctl.conf

change -> net.ipv4.ip_forward = 1

sysctl -p


# 給eth0接口添加網(wǎng)段

ip addr add 192.168.170.1/24 dev eth0

iptables -t nat -A POSTROUTING -s 192.168.170.0/24 -o eth0 -j MASQUERADE

iptables -t nat -I PREROUTING -p tcp -i eth0 -j REDSOCKS

# 注意 redsocks 配置綁定的 127.0.0.1 改成 0.0.0.0


/etc/NetworkManager/dispatcher.d/02addroute:?

#!/bin/bash

# Script to dispatch NetworkManager events

# Runs ifupdown scripts when NetworkManager fiddles with interfaces.

# See NetworkManager(8) for further documentation of the dispatcher events.

if [ -z "$1" ]; then

echo "$0: called with no interface" 1>&2

exit 1;

fi

if [[ "$1" == "eth0"? ]] && [[ "$2" == "up" ]]; then

ip addr add 192.168.170.1/24 dev eth0

fi

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容