在 ArchLinux 上设置 OpenConnect 服务器后没有互联网连接

在 ArchLinux 上设置 OpenConnect 服务器后没有互联网连接
ip tuntap add mode tun dev vpn0
ip addr add 192.168.2.2/24 dev vpn0

# systemctl restart ocserv
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 8443 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq state UP group default qlen 1000
    link/ether 56:00:04:c4:b9:c3 brd ff:ff:ff:ff:ff:ff
    inet 66.42.108.48/23 brd 66.42.109.255 scope global dynamic noprefixroute enp1s0
       valid_lft 85512sec preferred_lft 85512sec
    inet6 2001:19f0:6001:5689:5400:4ff:fec4:b9c3/64 scope global dynamic noprefixroute
       valid_lft 2591893sec preferred_lft 604693sec
    inet6 fe80::5400:4ff:fec4:b9c3/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: vpn0: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc fq state DOWN group default qlen 500
    link/none
    inet 192.168.2.2/24 scope global vpn0
       valid_lft forever preferred_lft forever
# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
#
# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
#
# sysctl -a | grep forwarding | grep ipv4
net.ipv4.conf.all.bc_forwarding = 0
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.all.mc_forwarding = 0
net.ipv4.conf.default.bc_forwarding = 0
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.default.mc_forwarding = 0
net.ipv4.conf.enp1s0.bc_forwarding = 0
net.ipv4.conf.enp1s0.forwarding = 1
net.ipv4.conf.enp1s0.mc_forwarding = 0
net.ipv4.conf.lo.bc_forwarding = 0
net.ipv4.conf.lo.forwarding = 1
net.ipv4.conf.lo.mc_forwarding = 0
net.ipv4.conf.vpn0.bc_forwarding = 0
net.ipv4.conf.vpn0.forwarding = 1
net.ipv4.conf.vpn0.mc_forwarding = 0
#

打开连接配置:

device = vpns0
tcp-port = 8443
ipv4-network = 192.168.2.0/24
route = default

连接成功。互联网不工作。 ping 8.8.8.8不工作。vpn 服务器的 ping 工作正常。

从 Windows 家庭版 到 Linux VPS 的连接

答案1

您需要添加一条静态路由,通过默认接口路由互联网流量。类似这样的路由

ip route add default via <your_gateway_ip> dev enp1s0

相关内容