如何进行到代理服务器的源路由?

如何进行到代理服务器的源路由?

我有:

  • IP 设置为 192.168.8.1 的路由器
  • 计算机A的IP为192.168.8.11
  • IP 为 192.168.8.102 的代理服务器

我的网络 192.168.8.0/24。网关 192.168.8.1

我想将所有流量从 ComputerA 路由到代理服务器。

我曾尝试添加一条新规则,但没有成功。

以下是我遵循的步骤:

#ip rule list
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

# ip route show table main
default via 72.xxx.0.1 dev eth0
10.8.8.0/24 via 10.8.8.2 dev tun21
10.8.8.2 dev tun21  proto kernel  scope link  src 10.8.8.1
72.xxx.0.0/21 dev eth0  proto kernel  scope link  src 72.xxx.1.31
72.xxx.0.1 dev eth0  proto kernel  scope link
127.0.0.0/8 dev lo  scope link
192.168.8.0/24 dev br0  proto kernel  scope link  src 192.168.8.1
239.0.0.0/8 dev br0  scope link

然后我添加规则:

ip rule add from 192.168.8.11 table 11

然后是路线:

ip route add default via 192.168.8.102 dev br0 table 11 metric 1

我确保更改确实存在:

#  ip rule list
0:      from all lookup local
32765:  from 192.168.8.11 lookup 11
32766:  from all lookup main
32767:  from all lookup default

#  ip route show table 11
default via 192.168.8.102 dev br0  metric 1

但是,似乎不起作用...知道我做错了什么吗?谢谢。

这里有一些额外的信息:

# ip addr
1: lo: <LOOPBACK,MULTICAST,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
2: ifb0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 32
    link/ether 00:11:22:33:44:66 brd ff:ff:ff:ff:ff:ff
3: ifb1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 32
    link/ether 00:11:22:33:44:77 brd ff:ff:ff:ff:ff:ff
4: imq0: <NOARP> mtu 16000 qdisc noop state DOWN group default qlen 11000
    link/void
5: imq1: <NOARP> mtu 16000 qdisc noop state DOWN group default qlen 11000
    link/void
6: imq2: <NOARP> mtu 16000 qdisc noop state DOWN group default qlen 11000
    link/void
7: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default
    link/sit 0.0.0.0 brd 0.0.0.0
8: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN group default
    link/tunnel6 :: brd ::
9: ip6gre0@NONE: <NOARP> mtu 1448 qdisc noop state DOWN group default
    link/gre6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
10: archer: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
11: bcmsw: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
12: eth0: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
    inet 72.xxx.xxx.xxx/21 brd 72.xxx.xxx.255 scope global eth0
       valid_lft forever preferred_lft forever
13: eth1: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
14: eth2: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
15: eth3: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
16: eth4: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
17: spu_us_dummy: <NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
18: spu_ds_dummy: <NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
19: dpsta: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
20: eth5: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
21: eth6: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether d4:5d:64:c6:4b:7c brd ff:ff:ff:ff:ff:ff
26: br0: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
    inet 192.168.8.1/24 brd 192.168.8.255 scope global br0
       valid_lft forever preferred_lft forever
27: tun21: <POINTOPOINT,MULTICAST,NOARP,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 100
    link/none
    inet 10.8.8.1 peer 10.8.8.2/32 scope global tun21
       valid_lft forever preferred_lft forever

相关内容