File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ layout : post
3+ title : " Set your linux route to access both side of firewall-通过设置Route如何同时访问防火墙内网和外网"
4+ date : 2020-09-24
5+ desc : " "
6+ keywords : " proxy, firewall, httpproxy"
7+ categories : [Life]
8+ tags : [network,proxy]
9+ icon : icon-html
10+ ---
11+
12+ # 要解决的问题
13+ 要么访问内网,要么访问外网, 来回切换很麻烦。 一般有两种情况
14+
15+ * 企业里面经常有防火墙,连接网线后 就是内网 无法访问外网。
16+
17+ # 方案
18+ 下面命令 使用与Linux
19+ 192.168.41.254是有线网卡 连接的网关
20+ 172.31.0.0/16是指目标网段 走有线
21+
22+
23+ ``` bash
24+ # 使用ip route查看本机路由表
25+ ip route
26+ default via 192.168.2.1 dev wlp4s0 proto dhcp metric 600 < -这个是默认路由表 经过无线网卡
27+ 10.0.0.0/8 via 10.72.8.1 dev tun0 proto static metric 50 < - 10.0.0.0/8网端走的是vpn 虚拟网卡tun0通道
28+ 10.72.8.0/22 dev tun0 proto kernel scope link src 10.72.8.19 metric 50
29+
30+ # 使用route add命令添加特点网卡 经过无线网卡网关
31+ sudo route add -net 172.31.0.0/16 gw 192.168.41.254 enp0s31f6
32+ sudo route add -net 172.30.0.0/16 gw 192.168.41.254 enp0s31f6
33+ sudo route add -net 192.168.26.0/24 gw 192.168.41.254 enp0s31f6
34+ sudo route add -net 10.150.175.0/24 gw 192.168.41.254 enp0s31f6
35+
36+ ```
37+
38+
You can’t perform that action at this time.
0 commit comments