3

I want to be able having 2 wg interfaces on same machine and tunnel traffic from one to another.

Every setup I found is basically begin with "setup your server peer on dedicated instance" but I need this kind of installation for testing configurations locally before pushing to remote instance.

The configuration that was used I just took from project homepage:

# client config
[Interface]
PrivateKey = wg1-private-key
ListenPort = 4201

[Peer]
PublicKey = wg0-public-key
Endpoint = 127.0.0.1:4200
AllowedIPs = 0.0.0.0/0, ::/0
# server config
[Interface]
PrivateKey = wg0-private-key
ListenPort = 4200

[Peer]
PublicKey = wg1-public-key
AllowedIPs = 0.0.0.0/0, ::/0

And then set up interfaces like this:

# client setup
~ # ip link add dev wg1 type wireguard
~ # ip addr add 10.1.0.2/24 dev wg1
~ # wg setconf wg1 client-config.ini
~ # ip link set up dev wg1
# server setup
~ # ip link add dev wg0 type wireguard
~ # ip addr add 10.1.0.1/24 dev wg0
~ # wg setconf wg0 server-config.ini
~ # ip link set up dev wg0

When I try to ping -I wg0 10.1.0.2 or ping -I wg1 10.1.0.1 I see the motion in tcpdump but don't get any response from receiving part.

Probably I need to do some work on proper routing but I'm not sure how exactly it should be done.

1
  • For testing purposes, use network namespaces so you get multiple network stacks and not just the single one which attempts to use the loopback interface. To see how complex it becomes without namespaces (not even involving WireGuard there), look at this answer I made on UL SE: unix.stackexchange.com/questions/655602/…
    – A.B
    Commented Jan 20, 2022 at 23:22

0

You must log in to answer this question.

Browse other questions tagged .