I've observed a somewhat strange behavior that I can't quite understand. So I set up an OpenVPN connection as shown in the graphic below. (It's a TUN and client-to-client setup). My thoughts are directed towards the route of ping in this scenario: my openvpn connection
from client: 192.168.200.102 to LAN: 10.198.0.16
In general, it's nothing surprising that this ping is successful, but for my comprehensions, in case when I change my iptables settings on the server to
-P FORWARD DROP
and then even
net.ipv4.ip_forward = 0.
the traffic should never reach the destination with the above settings. Although the traffic is successful, it kinda never does reach the LAN interface. The thing is I can't see the traffic (by running tcpdump data-network packet analyzer) arriving at the LAN interface eth0 10.198.0.16. More it seems that the tun interface is self answering the traffic, like if the LAN IP was bind to the tun interface, see below:
sudo tcpdump -i tun0 tcpdump: 16:34:21.391381 IP 192.168.200.102 > 10.198.0.16: ICMP echo request, id 14, seq 1885, length 64 16:34:21.391514 IP 10.198.0.16 > 192.168.200.102: ICMP echo reply, id 14, seq 1885, length 64
What's is happening here? As far as I understand, the request coming from the Client goes to tun interface on the server and will be eventually FORWARDED by the kernel to eth0, am I right? Would that normally be visible by running:sudo tcpdump -i tun0
or sudo tcpdump -i eth0
?
Why I'm so picky about this thing is that I consider it a security risk if there isn't a way to implement rules to prevent Clients from accessing the LAN on the server. What am I missing here, is there an OpenVPN process that itself forwards packets to the eth0 interface (as intended for client-to-client configuration)?
To let you better help me out of my problem I attached some diagnostic below.
For the Server
ip addr
`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 valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether b8:27:eb:5c:a6:e6 brd ff:ff:ff:ff:ff:ff inet 10.198.0.16/24 brd 10.198.0.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::ba27:ebff:fe5c:a6e6/64 scope link valid_lft forever preferred_lft forever 3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether b8:27:eb:09:f3:b3 brd ff:ff:ff:ff:ff:ff 4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500 link/none inet 192.168.200.1/24 scope global tun0 valid_lft forever preferred_lft forever inet6 fe80::87cd:fedd:92fc:cde/64 scope link stable-privacy valid_lft forever preferred_lft forever
`
ip route
default via 10.198.0.1 dev eth0 proto static 10.198.0.0/24 dev eth0 proto kernel scope link src 10.198.0.16 192.168.200.0/24 dev tun0 proto kernel scope link src 192.168.200.1 192.168.178.0/24 via 192.168.200.1 dev tun0 scope link
server openvpn.conf
tls-server mode server dev tun local 10.198.0.16 proto tcp-server port 1234 user openvpn group openvpn ca /etc/openvpn/cacert.pem cert /etc/openvpn/servercert.pem key /etc/openvpn/serverkey dh /etc/openvpn/dh2048.pem ifconfig-pool 192.168.200.2 192.168.200.103 255.255.255.0 client-config-dir /etc/openvpn/ccd ifconfig 192.168.200.1 255.255.255.0 keepalive 10 120 comp-lzo client-to-client push "topology subnet" topology "subnet" log /var/log/openvpn.log
For the Client
ip addr
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 valid_lft forever preferred_lft forever 2: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 38:af:d7:a0:52:ec brd ff:ff:ff:ff:ff:ff 3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:28:f8:8d:1c:6f brd ff:ff:ff:ff:ff:ff inet 192.168.178.79/24 brd 192.168.178.255 scope global dynamic noprefixroute wlp2s0 valid_lft 859868sec preferred_lft 859868sec inet6 2a0a:a540:d54:0:bd79:eb10:5e26:548a/64 scope global temporary dynamic valid_lft 7190sec preferred_lft 3590sec inet6 2a0a:a540:d54:0:6086:b044:dff:2694/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 7190sec preferred_lft 3590sec inet6 fe80::ad5c:6e18:87fa:dff4/64 scope link noprefixroute valid_lft forever preferred_lft forever 4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100 link/none inet 192.168.200.102/24 brd 192.168.200.255 scope global tun0 valid_lft forever preferred_lft forever inet6 fe80::5dfc:6b3a:3c4d:e9a4/64 scope link stable-privacy valid_lft forever preferred_lft forever
ip route
default via 192.168.178.1 dev wlp2s0 proto dhcp metric 600 169.254.0.0/16 dev wlp2s0 scope link metric 1000 10.198.0.0/24 via 192.168.200.1 dev tun0 192.168.200.0/24 dev tun0 proto kernel scope link src 192.168.200.102 192.168.178.0/24 dev wlp2s0 proto kernel scope link src 192.168.178.79 metric 600
client openvpn.conf
dev tun client nobind remote 11.22.33.44 proto tcp port 1234 ca /etc/openvpn/cacert.pem cert /etc/openvpn/user_cert.pem key /etc/openvpn/user comp-lzo verb 3 keepalive 10 120 log /var/log/openvpn.log
ccd for client
iroute 192.168.178.0 255.255.255.0