0
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
#

openconnect config:

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

Connection success. Internet do not works. ping 8.8.8.8 not work. ping of vpn server works.

Connection from Windows home to Linux VPS

1
  • Please provide your routes ip route show. You probably need to use split tunneling to not route internet traffic over the vpn, but route it through your default interface
    – Turdie
    Commented Feb 17 at 16:27

1 Answer 1

0

You need add a static route which routes internet traffic over your default interface. Something like this

ip route add default via <your_gateway_ip> dev enp1s0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .