Simple VPN routing configuration











up vote
0
down vote

favorite












I have a very simple VPN setup using tinc that works perfectly well. I would like to be able to route WAN traffic through one host, but I cannot seem to figure out how to get the routing table correct.



Host A (server):



eth0 -> WAN -> <publicip>



tun0 -> VPN -> 10.0.0.1



Host B (client):



wlp6s0 -> LAN -> 10.0.1.27



tun0 -> VPN -> 10.0.0.3



Here is what I have done so far:



On the server side, enabled IP forwarding and masquerade in iptables:



# iptables -t nat -A POSTROUTING -s 10.0.0.3 -o eth0 -j MASQUERADE



Here is what my client table looks like before touching the routing table:



default via 10.0.1.1 dev wlp6s0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303


As you can see, 10.0.1.1 is the LAN gateway. Both the client and server are able to ping each other over the VPN.



Now, what I have tried to apply to the routing table on the client:



# ip route add <publicip> via 10.0.1.1  # so that I don't take down tunnel as in https://unix.stackexchange.com/questions/420633
# ip route del default via 10.0.1.1
# ip route add default via 10.0.0.1


My table now looks like so:



default via 10.0.0.1 dev tun0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303
<publicip> via 10.0.1.1 dev wlp6s0


I am still able to pass traffic back and forth between client and server over VPN tunnel. But, WLAN-destined traffic from the client returns "Destination Net Unknown" and I do not see any incoming packets on the server side. What am I doing wrong?










share|improve this question






















  • Are there any NAT rules on the client? What does ip route get 1.1.1.1 show on the client?
    – wurtel
    Nov 19 at 15:08










  • It gives me the expected route, at least as I read it: 1.1.1.1 via 10.0.0.1 dev tun0 src 10.0.0.3 uid 1000 But a tracepath never even makes it to the gateway: 1?: [LOCALHOST] pmtu 1500 1: ??? 0.067ms !N 1: ??? 0.100ms !N
    – matoro
    Nov 19 at 19:31












  • Hmm, no idea, besides maybe you have iptables rules getting in the way?
    – wurtel
    Nov 20 at 7:45















up vote
0
down vote

favorite












I have a very simple VPN setup using tinc that works perfectly well. I would like to be able to route WAN traffic through one host, but I cannot seem to figure out how to get the routing table correct.



Host A (server):



eth0 -> WAN -> <publicip>



tun0 -> VPN -> 10.0.0.1



Host B (client):



wlp6s0 -> LAN -> 10.0.1.27



tun0 -> VPN -> 10.0.0.3



Here is what I have done so far:



On the server side, enabled IP forwarding and masquerade in iptables:



# iptables -t nat -A POSTROUTING -s 10.0.0.3 -o eth0 -j MASQUERADE



Here is what my client table looks like before touching the routing table:



default via 10.0.1.1 dev wlp6s0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303


As you can see, 10.0.1.1 is the LAN gateway. Both the client and server are able to ping each other over the VPN.



Now, what I have tried to apply to the routing table on the client:



# ip route add <publicip> via 10.0.1.1  # so that I don't take down tunnel as in https://unix.stackexchange.com/questions/420633
# ip route del default via 10.0.1.1
# ip route add default via 10.0.0.1


My table now looks like so:



default via 10.0.0.1 dev tun0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303
<publicip> via 10.0.1.1 dev wlp6s0


I am still able to pass traffic back and forth between client and server over VPN tunnel. But, WLAN-destined traffic from the client returns "Destination Net Unknown" and I do not see any incoming packets on the server side. What am I doing wrong?










share|improve this question






















  • Are there any NAT rules on the client? What does ip route get 1.1.1.1 show on the client?
    – wurtel
    Nov 19 at 15:08










  • It gives me the expected route, at least as I read it: 1.1.1.1 via 10.0.0.1 dev tun0 src 10.0.0.3 uid 1000 But a tracepath never even makes it to the gateway: 1?: [LOCALHOST] pmtu 1500 1: ??? 0.067ms !N 1: ??? 0.100ms !N
    – matoro
    Nov 19 at 19:31












  • Hmm, no idea, besides maybe you have iptables rules getting in the way?
    – wurtel
    Nov 20 at 7:45













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a very simple VPN setup using tinc that works perfectly well. I would like to be able to route WAN traffic through one host, but I cannot seem to figure out how to get the routing table correct.



Host A (server):



eth0 -> WAN -> <publicip>



tun0 -> VPN -> 10.0.0.1



Host B (client):



wlp6s0 -> LAN -> 10.0.1.27



tun0 -> VPN -> 10.0.0.3



Here is what I have done so far:



On the server side, enabled IP forwarding and masquerade in iptables:



# iptables -t nat -A POSTROUTING -s 10.0.0.3 -o eth0 -j MASQUERADE



Here is what my client table looks like before touching the routing table:



default via 10.0.1.1 dev wlp6s0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303


As you can see, 10.0.1.1 is the LAN gateway. Both the client and server are able to ping each other over the VPN.



Now, what I have tried to apply to the routing table on the client:



# ip route add <publicip> via 10.0.1.1  # so that I don't take down tunnel as in https://unix.stackexchange.com/questions/420633
# ip route del default via 10.0.1.1
# ip route add default via 10.0.0.1


My table now looks like so:



default via 10.0.0.1 dev tun0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303
<publicip> via 10.0.1.1 dev wlp6s0


I am still able to pass traffic back and forth between client and server over VPN tunnel. But, WLAN-destined traffic from the client returns "Destination Net Unknown" and I do not see any incoming packets on the server side. What am I doing wrong?










share|improve this question













I have a very simple VPN setup using tinc that works perfectly well. I would like to be able to route WAN traffic through one host, but I cannot seem to figure out how to get the routing table correct.



Host A (server):



eth0 -> WAN -> <publicip>



tun0 -> VPN -> 10.0.0.1



Host B (client):



wlp6s0 -> LAN -> 10.0.1.27



tun0 -> VPN -> 10.0.0.3



Here is what I have done so far:



On the server side, enabled IP forwarding and masquerade in iptables:



# iptables -t nat -A POSTROUTING -s 10.0.0.3 -o eth0 -j MASQUERADE



Here is what my client table looks like before touching the routing table:



default via 10.0.1.1 dev wlp6s0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303


As you can see, 10.0.1.1 is the LAN gateway. Both the client and server are able to ping each other over the VPN.



Now, what I have tried to apply to the routing table on the client:



# ip route add <publicip> via 10.0.1.1  # so that I don't take down tunnel as in https://unix.stackexchange.com/questions/420633
# ip route del default via 10.0.1.1
# ip route add default via 10.0.0.1


My table now looks like so:



default via 10.0.0.1 dev tun0 
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.3
10.0.1.0/24 dev wlp6s0 proto dhcp scope link src 10.0.1.27 metric 303
<publicip> via 10.0.1.1 dev wlp6s0


I am still able to pass traffic back and forth between client and server over VPN tunnel. But, WLAN-destined traffic from the client returns "Destination Net Unknown" and I do not see any incoming packets on the server side. What am I doing wrong?







routing vpn nat iproute






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 3:06









matoro

32




32












  • Are there any NAT rules on the client? What does ip route get 1.1.1.1 show on the client?
    – wurtel
    Nov 19 at 15:08










  • It gives me the expected route, at least as I read it: 1.1.1.1 via 10.0.0.1 dev tun0 src 10.0.0.3 uid 1000 But a tracepath never even makes it to the gateway: 1?: [LOCALHOST] pmtu 1500 1: ??? 0.067ms !N 1: ??? 0.100ms !N
    – matoro
    Nov 19 at 19:31












  • Hmm, no idea, besides maybe you have iptables rules getting in the way?
    – wurtel
    Nov 20 at 7:45


















  • Are there any NAT rules on the client? What does ip route get 1.1.1.1 show on the client?
    – wurtel
    Nov 19 at 15:08










  • It gives me the expected route, at least as I read it: 1.1.1.1 via 10.0.0.1 dev tun0 src 10.0.0.3 uid 1000 But a tracepath never even makes it to the gateway: 1?: [LOCALHOST] pmtu 1500 1: ??? 0.067ms !N 1: ??? 0.100ms !N
    – matoro
    Nov 19 at 19:31












  • Hmm, no idea, besides maybe you have iptables rules getting in the way?
    – wurtel
    Nov 20 at 7:45
















Are there any NAT rules on the client? What does ip route get 1.1.1.1 show on the client?
– wurtel
Nov 19 at 15:08




Are there any NAT rules on the client? What does ip route get 1.1.1.1 show on the client?
– wurtel
Nov 19 at 15:08












It gives me the expected route, at least as I read it: 1.1.1.1 via 10.0.0.1 dev tun0 src 10.0.0.3 uid 1000 But a tracepath never even makes it to the gateway: 1?: [LOCALHOST] pmtu 1500 1: ??? 0.067ms !N 1: ??? 0.100ms !N
– matoro
Nov 19 at 19:31






It gives me the expected route, at least as I read it: 1.1.1.1 via 10.0.0.1 dev tun0 src 10.0.0.3 uid 1000 But a tracepath never even makes it to the gateway: 1?: [LOCALHOST] pmtu 1500 1: ??? 0.067ms !N 1: ??? 0.100ms !N
– matoro
Nov 19 at 19:31














Hmm, no idea, besides maybe you have iptables rules getting in the way?
– wurtel
Nov 20 at 7:45




Hmm, no idea, besides maybe you have iptables rules getting in the way?
– wurtel
Nov 20 at 7:45















active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482654%2fsimple-vpn-routing-configuration%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482654%2fsimple-vpn-routing-configuration%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Morgemoulin

Scott Moir

Souastre