0

I have Linux VM in my local network, with OpenVPN perfectly working on it. Let's say my main gateway (router, actually) is 192.168.1.1, VM ip is 192.168.1.15. That's my VM network settings on the interface connected to the Internet:

auto eth0
iface eth0 inet static
address 192.168.1.15
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8

route -n output before start of OpenVPN:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
10.60.165.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

And after start of OpenVPN:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
10.10.10.0      10.80.165.1     255.255.255.0   UG    0      0        0 game
10.60.0.0       10.80.165.1     255.252.0.0     UG    0      0        0 game
10.60.165.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
10.80.0.0       10.80.165.1     255.252.0.0     UG    0      0        0 game
10.80.165.1     0.0.0.0         255.255.255.255 UH    0      0        0 game
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

From other machines I need to connect to ip 10.80.156.1 through VM. So, I set the gateway on other machine to ip of VM. I can access Internet this way, but address 10.80.156.1 is unreachable.

UPD: iptables -L -n output:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 
  • Show your iptables rules on VM. – Ipor Sircer Nov 9 '16 at 16:06
  • @IporSircer, see updated answer – nikrom3000 Nov 9 '16 at 16:30
  • I meant all tables. Especially nat. See answer. – Ipor Sircer Nov 9 '16 at 16:32
1

I don't believe you can reach internet from any machine which use 192.168.1.15 as default gateway. You have to nat the connection:

iptables -A POSTROUTING -t nat -j MASQUERADE
  • That worked! I found my mistake. Haven't considered rebooting the machine resets iptables rules – nikrom3000 Nov 9 '16 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.