How to make specific programs use wireguard in arch linux?












1















I'd like to have only one program run through a wireguard config I have stored at /etc/wireguard/config.conf, and all the other programs run through the normal IP address.



I've found this page in the wireguard use on routing, which suggests using namespaces, but when I try to run some of the commands, such as



sudo ip link set wlp2s0 netns physical
RTNETLINK answers: Invalid argument


Suggesting this can't be done through arch linux. Has anyone found a way to get specific programs to run through wireguard?





I tried the above tutorial on a different machine, and I get the following error when trying to load my wireguard config.



wg setconf wgvpn0 /etc/wireguard/my_vpn.conf : invalid format, yet the same config works perfectly when using wg-quick up



Side point, does anyone know of any issue tracking system for wireguard? The questions I submit to their mailing list aren't publicly available.










share|improve this question

























  • What does your wireguard config look like, and what output do you get from # lsns -l?

    – Torxed
    Nov 24 '18 at 9:44











  • lsns -l just has a bunch of entries for syncthing only, and wireguard config looks like: ``` [Interface] PrivateKey = Address = DNS = [Peer] PublicKey = AllowedIPs = Endpoint = ```

    – thouliha
    Nov 24 '18 at 18:21











  • Does the wlp2s0 interface exists on your system? It seems that it's an Wifi interface, not a wireguard one (usually wg0). Please post the ip link list of your system after connecting to that vpn...

    – nwildner
    Jan 7 at 13:08











  • there is a third one for wireguard after connecting to it.

    – thouliha
    Jan 8 at 2:06






  • 1





    I don't see evidence to support the current close-votes indicating "off-topic, can't reproduced." It seems to me from A.B.'s comment that there's a potential answer waiting here...

    – Jeff Schaller
    Jan 11 at 15:27
















1















I'd like to have only one program run through a wireguard config I have stored at /etc/wireguard/config.conf, and all the other programs run through the normal IP address.



I've found this page in the wireguard use on routing, which suggests using namespaces, but when I try to run some of the commands, such as



sudo ip link set wlp2s0 netns physical
RTNETLINK answers: Invalid argument


Suggesting this can't be done through arch linux. Has anyone found a way to get specific programs to run through wireguard?





I tried the above tutorial on a different machine, and I get the following error when trying to load my wireguard config.



wg setconf wgvpn0 /etc/wireguard/my_vpn.conf : invalid format, yet the same config works perfectly when using wg-quick up



Side point, does anyone know of any issue tracking system for wireguard? The questions I submit to their mailing list aren't publicly available.










share|improve this question

























  • What does your wireguard config look like, and what output do you get from # lsns -l?

    – Torxed
    Nov 24 '18 at 9:44











  • lsns -l just has a bunch of entries for syncthing only, and wireguard config looks like: ``` [Interface] PrivateKey = Address = DNS = [Peer] PublicKey = AllowedIPs = Endpoint = ```

    – thouliha
    Nov 24 '18 at 18:21











  • Does the wlp2s0 interface exists on your system? It seems that it's an Wifi interface, not a wireguard one (usually wg0). Please post the ip link list of your system after connecting to that vpn...

    – nwildner
    Jan 7 at 13:08











  • there is a third one for wireguard after connecting to it.

    – thouliha
    Jan 8 at 2:06






  • 1





    I don't see evidence to support the current close-votes indicating "off-topic, can't reproduced." It seems to me from A.B.'s comment that there's a potential answer waiting here...

    – Jeff Schaller
    Jan 11 at 15:27














1












1








1








I'd like to have only one program run through a wireguard config I have stored at /etc/wireguard/config.conf, and all the other programs run through the normal IP address.



I've found this page in the wireguard use on routing, which suggests using namespaces, but when I try to run some of the commands, such as



sudo ip link set wlp2s0 netns physical
RTNETLINK answers: Invalid argument


Suggesting this can't be done through arch linux. Has anyone found a way to get specific programs to run through wireguard?





I tried the above tutorial on a different machine, and I get the following error when trying to load my wireguard config.



wg setconf wgvpn0 /etc/wireguard/my_vpn.conf : invalid format, yet the same config works perfectly when using wg-quick up



Side point, does anyone know of any issue tracking system for wireguard? The questions I submit to their mailing list aren't publicly available.










share|improve this question
















I'd like to have only one program run through a wireguard config I have stored at /etc/wireguard/config.conf, and all the other programs run through the normal IP address.



I've found this page in the wireguard use on routing, which suggests using namespaces, but when I try to run some of the commands, such as



sudo ip link set wlp2s0 netns physical
RTNETLINK answers: Invalid argument


Suggesting this can't be done through arch linux. Has anyone found a way to get specific programs to run through wireguard?





I tried the above tutorial on a different machine, and I get the following error when trying to load my wireguard config.



wg setconf wgvpn0 /etc/wireguard/my_vpn.conf : invalid format, yet the same config works perfectly when using wg-quick up



Side point, does anyone know of any issue tracking system for wireguard? The questions I submit to their mailing list aren't publicly available.







arch-linux vpn






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







thouliha

















asked Nov 23 '18 at 17:28









thoulihathouliha

1063




1063













  • What does your wireguard config look like, and what output do you get from # lsns -l?

    – Torxed
    Nov 24 '18 at 9:44











  • lsns -l just has a bunch of entries for syncthing only, and wireguard config looks like: ``` [Interface] PrivateKey = Address = DNS = [Peer] PublicKey = AllowedIPs = Endpoint = ```

    – thouliha
    Nov 24 '18 at 18:21











  • Does the wlp2s0 interface exists on your system? It seems that it's an Wifi interface, not a wireguard one (usually wg0). Please post the ip link list of your system after connecting to that vpn...

    – nwildner
    Jan 7 at 13:08











  • there is a third one for wireguard after connecting to it.

    – thouliha
    Jan 8 at 2:06






  • 1





    I don't see evidence to support the current close-votes indicating "off-topic, can't reproduced." It seems to me from A.B.'s comment that there's a potential answer waiting here...

    – Jeff Schaller
    Jan 11 at 15:27



















  • What does your wireguard config look like, and what output do you get from # lsns -l?

    – Torxed
    Nov 24 '18 at 9:44











  • lsns -l just has a bunch of entries for syncthing only, and wireguard config looks like: ``` [Interface] PrivateKey = Address = DNS = [Peer] PublicKey = AllowedIPs = Endpoint = ```

    – thouliha
    Nov 24 '18 at 18:21











  • Does the wlp2s0 interface exists on your system? It seems that it's an Wifi interface, not a wireguard one (usually wg0). Please post the ip link list of your system after connecting to that vpn...

    – nwildner
    Jan 7 at 13:08











  • there is a third one for wireguard after connecting to it.

    – thouliha
    Jan 8 at 2:06






  • 1





    I don't see evidence to support the current close-votes indicating "off-topic, can't reproduced." It seems to me from A.B.'s comment that there's a potential answer waiting here...

    – Jeff Schaller
    Jan 11 at 15:27

















What does your wireguard config look like, and what output do you get from # lsns -l?

– Torxed
Nov 24 '18 at 9:44





What does your wireguard config look like, and what output do you get from # lsns -l?

– Torxed
Nov 24 '18 at 9:44













lsns -l just has a bunch of entries for syncthing only, and wireguard config looks like: ``` [Interface] PrivateKey = Address = DNS = [Peer] PublicKey = AllowedIPs = Endpoint = ```

– thouliha
Nov 24 '18 at 18:21





lsns -l just has a bunch of entries for syncthing only, and wireguard config looks like: ``` [Interface] PrivateKey = Address = DNS = [Peer] PublicKey = AllowedIPs = Endpoint = ```

– thouliha
Nov 24 '18 at 18:21













Does the wlp2s0 interface exists on your system? It seems that it's an Wifi interface, not a wireguard one (usually wg0). Please post the ip link list of your system after connecting to that vpn...

– nwildner
Jan 7 at 13:08





Does the wlp2s0 interface exists on your system? It seems that it's an Wifi interface, not a wireguard one (usually wg0). Please post the ip link list of your system after connecting to that vpn...

– nwildner
Jan 7 at 13:08













there is a third one for wireguard after connecting to it.

– thouliha
Jan 8 at 2:06





there is a third one for wireguard after connecting to it.

– thouliha
Jan 8 at 2:06




1




1





I don't see evidence to support the current close-votes indicating "off-topic, can't reproduced." It seems to me from A.B.'s comment that there's a potential answer waiting here...

– Jeff Schaller
Jan 11 at 15:27





I don't see evidence to support the current close-votes indicating "off-topic, can't reproduced." It seems to me from A.B.'s comment that there's a potential answer waiting here...

– Jeff Schaller
Jan 11 at 15:27










1 Answer
1






active

oldest

votes


















1














From the wireguard.com's link provided in OP's question, specifically in The New Namespace Solution, it's explained how to move physical interfaces, with an ethernet and a wireless example, bold emphasis mine:




Physical Network Namespace Diagram
First we create the "physical" network namespace:



# ip netns add physical


Now we move eth0 and wlan0 into the "physical" namespace:



# ip link set eth0 netns physical
# iw phy phy0 set netns name physical


(Note that wireless devices must be moved using iw and by
specifying the physical device phy0.
)




it appears OP read the first ip link set ... netns command, but didn't see that the second command was needed instead for a wireless device, as noted.



iw's manual page is scarce, but iw --help includes:




   phy <phyname> set netns { <pid> | name <nsname> }
Put this wireless device into a different network namespace:
<pid> - change network namespace by process id
<nsname> - change network namespace by name from /run/netns
or by absolute path (man ip-netns)



Some drivers might not yet be compatible with network namespaces. This output is required for it to work:



$ sudo iw phy0 info|grep netns
* set_wiphy_netns


Assuming there's only one simple wireless device, wlp2s0 is handled by iw via its phy0 counterpart, so won't appear at all in the command. This must be used:



sudo iw phy phy0 set netns name physical





share|improve this answer
























  • After I run those two commands, it disconnects my wireless connection, and my ip addr command no longer shows my wireless card. I can only recover by running: sudo ip netns delete physical sudo systemctl restart NetworkManager

    – thouliha
    Jan 13 at 1:44











  • Also the wg setconf wgvpn0 /etc/wireguard/my_vpn.conf command fails, saying its an invalid format, yet it works perfectly when using wg-quick up. I really wish wireguard had an open issue tracking system.

    – thouliha
    Jan 13 at 1:52











  • It's expected to lose access (from init namespace) to the interface when you move it: no bug or issue. Maybe you didn't unsterstand the goal of the tutorial. As for the my_vpn.conf I see no trace of it, nor any trace of NetworkManager. Are you still following the tutorial you linked?

    – A.B
    Jan 13 at 9:29













  • So how do I get access then? This answer still doesn't help me solve my overall goal, getting specific programs to use wireguard in arch linux. Also yes I'm still trying to follow their tutorial, although it doesn't work.

    – thouliha
    Jan 13 at 16:39











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',
autoActivateHeartbeat: false,
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%2f483731%2fhow-to-make-specific-programs-use-wireguard-in-arch-linux%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














From the wireguard.com's link provided in OP's question, specifically in The New Namespace Solution, it's explained how to move physical interfaces, with an ethernet and a wireless example, bold emphasis mine:




Physical Network Namespace Diagram
First we create the "physical" network namespace:



# ip netns add physical


Now we move eth0 and wlan0 into the "physical" namespace:



# ip link set eth0 netns physical
# iw phy phy0 set netns name physical


(Note that wireless devices must be moved using iw and by
specifying the physical device phy0.
)




it appears OP read the first ip link set ... netns command, but didn't see that the second command was needed instead for a wireless device, as noted.



iw's manual page is scarce, but iw --help includes:




   phy <phyname> set netns { <pid> | name <nsname> }
Put this wireless device into a different network namespace:
<pid> - change network namespace by process id
<nsname> - change network namespace by name from /run/netns
or by absolute path (man ip-netns)



Some drivers might not yet be compatible with network namespaces. This output is required for it to work:



$ sudo iw phy0 info|grep netns
* set_wiphy_netns


Assuming there's only one simple wireless device, wlp2s0 is handled by iw via its phy0 counterpart, so won't appear at all in the command. This must be used:



sudo iw phy phy0 set netns name physical





share|improve this answer
























  • After I run those two commands, it disconnects my wireless connection, and my ip addr command no longer shows my wireless card. I can only recover by running: sudo ip netns delete physical sudo systemctl restart NetworkManager

    – thouliha
    Jan 13 at 1:44











  • Also the wg setconf wgvpn0 /etc/wireguard/my_vpn.conf command fails, saying its an invalid format, yet it works perfectly when using wg-quick up. I really wish wireguard had an open issue tracking system.

    – thouliha
    Jan 13 at 1:52











  • It's expected to lose access (from init namespace) to the interface when you move it: no bug or issue. Maybe you didn't unsterstand the goal of the tutorial. As for the my_vpn.conf I see no trace of it, nor any trace of NetworkManager. Are you still following the tutorial you linked?

    – A.B
    Jan 13 at 9:29













  • So how do I get access then? This answer still doesn't help me solve my overall goal, getting specific programs to use wireguard in arch linux. Also yes I'm still trying to follow their tutorial, although it doesn't work.

    – thouliha
    Jan 13 at 16:39
















1














From the wireguard.com's link provided in OP's question, specifically in The New Namespace Solution, it's explained how to move physical interfaces, with an ethernet and a wireless example, bold emphasis mine:




Physical Network Namespace Diagram
First we create the "physical" network namespace:



# ip netns add physical


Now we move eth0 and wlan0 into the "physical" namespace:



# ip link set eth0 netns physical
# iw phy phy0 set netns name physical


(Note that wireless devices must be moved using iw and by
specifying the physical device phy0.
)




it appears OP read the first ip link set ... netns command, but didn't see that the second command was needed instead for a wireless device, as noted.



iw's manual page is scarce, but iw --help includes:




   phy <phyname> set netns { <pid> | name <nsname> }
Put this wireless device into a different network namespace:
<pid> - change network namespace by process id
<nsname> - change network namespace by name from /run/netns
or by absolute path (man ip-netns)



Some drivers might not yet be compatible with network namespaces. This output is required for it to work:



$ sudo iw phy0 info|grep netns
* set_wiphy_netns


Assuming there's only one simple wireless device, wlp2s0 is handled by iw via its phy0 counterpart, so won't appear at all in the command. This must be used:



sudo iw phy phy0 set netns name physical





share|improve this answer
























  • After I run those two commands, it disconnects my wireless connection, and my ip addr command no longer shows my wireless card. I can only recover by running: sudo ip netns delete physical sudo systemctl restart NetworkManager

    – thouliha
    Jan 13 at 1:44











  • Also the wg setconf wgvpn0 /etc/wireguard/my_vpn.conf command fails, saying its an invalid format, yet it works perfectly when using wg-quick up. I really wish wireguard had an open issue tracking system.

    – thouliha
    Jan 13 at 1:52











  • It's expected to lose access (from init namespace) to the interface when you move it: no bug or issue. Maybe you didn't unsterstand the goal of the tutorial. As for the my_vpn.conf I see no trace of it, nor any trace of NetworkManager. Are you still following the tutorial you linked?

    – A.B
    Jan 13 at 9:29













  • So how do I get access then? This answer still doesn't help me solve my overall goal, getting specific programs to use wireguard in arch linux. Also yes I'm still trying to follow their tutorial, although it doesn't work.

    – thouliha
    Jan 13 at 16:39














1












1








1







From the wireguard.com's link provided in OP's question, specifically in The New Namespace Solution, it's explained how to move physical interfaces, with an ethernet and a wireless example, bold emphasis mine:




Physical Network Namespace Diagram
First we create the "physical" network namespace:



# ip netns add physical


Now we move eth0 and wlan0 into the "physical" namespace:



# ip link set eth0 netns physical
# iw phy phy0 set netns name physical


(Note that wireless devices must be moved using iw and by
specifying the physical device phy0.
)




it appears OP read the first ip link set ... netns command, but didn't see that the second command was needed instead for a wireless device, as noted.



iw's manual page is scarce, but iw --help includes:




   phy <phyname> set netns { <pid> | name <nsname> }
Put this wireless device into a different network namespace:
<pid> - change network namespace by process id
<nsname> - change network namespace by name from /run/netns
or by absolute path (man ip-netns)



Some drivers might not yet be compatible with network namespaces. This output is required for it to work:



$ sudo iw phy0 info|grep netns
* set_wiphy_netns


Assuming there's only one simple wireless device, wlp2s0 is handled by iw via its phy0 counterpart, so won't appear at all in the command. This must be used:



sudo iw phy phy0 set netns name physical





share|improve this answer













From the wireguard.com's link provided in OP's question, specifically in The New Namespace Solution, it's explained how to move physical interfaces, with an ethernet and a wireless example, bold emphasis mine:




Physical Network Namespace Diagram
First we create the "physical" network namespace:



# ip netns add physical


Now we move eth0 and wlan0 into the "physical" namespace:



# ip link set eth0 netns physical
# iw phy phy0 set netns name physical


(Note that wireless devices must be moved using iw and by
specifying the physical device phy0.
)




it appears OP read the first ip link set ... netns command, but didn't see that the second command was needed instead for a wireless device, as noted.



iw's manual page is scarce, but iw --help includes:




   phy <phyname> set netns { <pid> | name <nsname> }
Put this wireless device into a different network namespace:
<pid> - change network namespace by process id
<nsname> - change network namespace by name from /run/netns
or by absolute path (man ip-netns)



Some drivers might not yet be compatible with network namespaces. This output is required for it to work:



$ sudo iw phy0 info|grep netns
* set_wiphy_netns


Assuming there's only one simple wireless device, wlp2s0 is handled by iw via its phy0 counterpart, so won't appear at all in the command. This must be used:



sudo iw phy phy0 set netns name physical






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 11 at 23:59









A.BA.B

4,2721724




4,2721724













  • After I run those two commands, it disconnects my wireless connection, and my ip addr command no longer shows my wireless card. I can only recover by running: sudo ip netns delete physical sudo systemctl restart NetworkManager

    – thouliha
    Jan 13 at 1:44











  • Also the wg setconf wgvpn0 /etc/wireguard/my_vpn.conf command fails, saying its an invalid format, yet it works perfectly when using wg-quick up. I really wish wireguard had an open issue tracking system.

    – thouliha
    Jan 13 at 1:52











  • It's expected to lose access (from init namespace) to the interface when you move it: no bug or issue. Maybe you didn't unsterstand the goal of the tutorial. As for the my_vpn.conf I see no trace of it, nor any trace of NetworkManager. Are you still following the tutorial you linked?

    – A.B
    Jan 13 at 9:29













  • So how do I get access then? This answer still doesn't help me solve my overall goal, getting specific programs to use wireguard in arch linux. Also yes I'm still trying to follow their tutorial, although it doesn't work.

    – thouliha
    Jan 13 at 16:39



















  • After I run those two commands, it disconnects my wireless connection, and my ip addr command no longer shows my wireless card. I can only recover by running: sudo ip netns delete physical sudo systemctl restart NetworkManager

    – thouliha
    Jan 13 at 1:44











  • Also the wg setconf wgvpn0 /etc/wireguard/my_vpn.conf command fails, saying its an invalid format, yet it works perfectly when using wg-quick up. I really wish wireguard had an open issue tracking system.

    – thouliha
    Jan 13 at 1:52











  • It's expected to lose access (from init namespace) to the interface when you move it: no bug or issue. Maybe you didn't unsterstand the goal of the tutorial. As for the my_vpn.conf I see no trace of it, nor any trace of NetworkManager. Are you still following the tutorial you linked?

    – A.B
    Jan 13 at 9:29













  • So how do I get access then? This answer still doesn't help me solve my overall goal, getting specific programs to use wireguard in arch linux. Also yes I'm still trying to follow their tutorial, although it doesn't work.

    – thouliha
    Jan 13 at 16:39

















After I run those two commands, it disconnects my wireless connection, and my ip addr command no longer shows my wireless card. I can only recover by running: sudo ip netns delete physical sudo systemctl restart NetworkManager

– thouliha
Jan 13 at 1:44





After I run those two commands, it disconnects my wireless connection, and my ip addr command no longer shows my wireless card. I can only recover by running: sudo ip netns delete physical sudo systemctl restart NetworkManager

– thouliha
Jan 13 at 1:44













Also the wg setconf wgvpn0 /etc/wireguard/my_vpn.conf command fails, saying its an invalid format, yet it works perfectly when using wg-quick up. I really wish wireguard had an open issue tracking system.

– thouliha
Jan 13 at 1:52





Also the wg setconf wgvpn0 /etc/wireguard/my_vpn.conf command fails, saying its an invalid format, yet it works perfectly when using wg-quick up. I really wish wireguard had an open issue tracking system.

– thouliha
Jan 13 at 1:52













It's expected to lose access (from init namespace) to the interface when you move it: no bug or issue. Maybe you didn't unsterstand the goal of the tutorial. As for the my_vpn.conf I see no trace of it, nor any trace of NetworkManager. Are you still following the tutorial you linked?

– A.B
Jan 13 at 9:29







It's expected to lose access (from init namespace) to the interface when you move it: no bug or issue. Maybe you didn't unsterstand the goal of the tutorial. As for the my_vpn.conf I see no trace of it, nor any trace of NetworkManager. Are you still following the tutorial you linked?

– A.B
Jan 13 at 9:29















So how do I get access then? This answer still doesn't help me solve my overall goal, getting specific programs to use wireguard in arch linux. Also yes I'm still trying to follow their tutorial, although it doesn't work.

– thouliha
Jan 13 at 16:39





So how do I get access then? This answer still doesn't help me solve my overall goal, getting specific programs to use wireguard in arch linux. Also yes I'm still trying to follow their tutorial, although it doesn't work.

– thouliha
Jan 13 at 16:39


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483731%2fhow-to-make-specific-programs-use-wireguard-in-arch-linux%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

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

19世紀