Code: Select all
cat /etc/wireguard/wg.conf
[Interface]
Address = 10.0.6.1/16
ListenPort = 45089
PrivateKey = [redacted]
# twin server
[Peer]
PublicKey = [redacted]
AllowedIPs = 10.0.6.2/32
Endpoint = [peers public IP]:45089
# mobile client, we don't know its IP in advance so it must send keepalive to maintain the connection. This is configured with PersistentKeepalive = 20 on the other machine in our matching Peer section
[Peer]
PublicKey = [redacted]
AllowedIPs = 10.0.6.230/32
The client config:[Interface]
Address = 10.8.0.1/32
ListenPort = nnnn
PrivateKey = redacted
[Peer]
PublicKey = redacted
AllowedIPs = 10.8.0.2/32
PersistentKeepalive = 20
My goal is to[Interface]
Address = 10.8.0.2/32
ListenPort = nnnn
PrivateKey = redacted
[Peer]
PublicKey = redacted
Endpoint = <public IP of remote server>:nnnn
AllowedIPs = 10.8.0.1/32
Code: Select all
curl ifconfig.meexactly, if you want to pass all your traffic through the tunnel replace 10.8.x.x/x on your client with 0.0.0.0/0DavidF wrote:If I understand what you are after ... Your tunnel to the remote server is only traffic on your private network 10.9.0.1/32. All other internet traffic will be using your isp ip. If you want all traffic to reflect the remote peer IP you need to add 0.0.0.0/0 to your AllowedIPs . That will tunnel all traffic through the remote server. Check it with whatsmyip to be sure.
Code: Select all
DNS = <your dns server>
My OVPN works just fine: my public IP is that of the server, and the mail server (postfix) running on the client works as well.andraslinux /etc/wireguard # wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.8.0.2/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] resolvconf -a wg0 -m 0 -x
[#] ip -4 route add 10.8.0.1/32 dev wg0
[#] wg set wg0 fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] iptables-restore -n
iptables-restore v1.8.7 (legacy): iptables-restore: unable to initialize table 'raw'
Error occurred at line: 1
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
[#] resolvconf -d wg0 -f
[#] ip -4 rule delete table 51820
[#] ip -4 rule delete table main suppress_prefixlength 0
[#] ip link delete dev wg0
andraslinux /etc/wireguard #
- My isp IP may not be the same all the time - I don't know. But my linode public P is stable.When you connect to the linode server via wireguard your endpoint ip server side will be your desktop isp ip.
Code: Select all
andraslinux /etc/wireguard # wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.8.0.2/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] resolvconf -a wg0 -m 0 -x
[#] ip -4 route add 10.8.0.1/32 dev wg0
\\\
andraslinux /etc/wireguard # wg show
interface: wg0
public key: blah-blah
private key: (hidden)
listening port: nnnn
peer: another-blah-blah
endpoint: <linode public IP>:nnnn
allowed ips: 10.8.0.1/32
\\\
andraslinux /etc/wireguard # wg-quick down wg0
[#] ip link delete dev wg0
[#] resolvconf -d wg0 -f
andraslinux /etc/wireguard # - don't know. It looks like, from "route -n" command, that linode eth0 is connected to a public ip gateway and has a permanent piblic IP on that same ARIN allocated ip pool.If so what is the subnet of your linode server?
Added my server public IP to clien configuration, but no handshaking, and my public IP on the client is still the ISP.andraslinux /etc/wireguard # wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.8.0.2/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] ip -4 route add <my server public IP>/32 dev wg0
[#] ip -4 route add 10.8.0.1/32 dev wg0
andraslinux /etc/wireguard # wg show
interface: wg0
public key: <gibberish>
private key: (hidden)
listening port: nnn
peer: <another gibberish>
endpoint: <my server public IP>:nnnn
allowed ips: 10.8.0.1/32, <my server public IP>/32
andraslinux /etc/wireguard #
Why?DavidF wrote:Try adding your public ip to allowed ips and see what happens.
perhaps .. AllowedIPs =10.8.0.0/24 , your.public.ip.xx/32
Looks like 192.168.72.139 is the local ip of the router on my isp and my client WiFi local ip is 192.168.72.11. On the server side client 10.8.0.2 wireguard private network ip is connecting to Internet so I can ping 10.8.0.1 or 10.8.0.2 from server or client as long as wg0 in active. But traffic from client 10.8.0.2 is routed through client isp and not through the tunnel. This is why the client's IP is that of the isp.# remote server (linode)
[Interface]
Address = 10.8.0.1/32
ListenPort = nnnn
PrivateKey = [redacted]
[Peer]
PublicKey = 28Q2MH3fqDvl4FtNVmhziq2vKTff4P26l/zpaEvpgQI=
AllowedIPs = 10.8.0.2/32
PersistentKeepalive = 20
# local client (Fitlet)
[Interface]
Address = 10.8.0.2/32
ListenPort = 17141
PrivateKey = [redacted]
[Peer]
# jgklinux (linode) with public IP
PublicKey = kIcG2Bh2SAzD7st8z3kL9esMxw1kwEB09slYGdatvnc=
Endpoint = <server public IP>:nnnn
AllowedIPs = 10.8.0.1/32
xxxxxxxxxxxxxxx
# ip route server
gellert@jgklinux ~ $ ip route
default via 198.74.55.1 dev eth0 proto dhcp src <server public ip> metric 1003
10.8.0.2 dev wg0 scope link
169.254.0.0/16 dev dummy0 scope link src 169.254.229.246 metric 1002
198.74.55.0/24 dev eth0 proto dhcp scope link src <server public ip> metric 1003
# ip route client
janos@andraslinux ~ $ ip route
default via 192.168.72.139 dev wlan0 proto dhcp src 192.168.72.11 metric 3006
10.8.0.1 dev wg0 scope link
192.168.72.0/24 dev wlan0 proto dhcp scope link src 192.168.72.11 metric 3006
It can. It's particularly convenient for mobile stations, you can change ISP without breaking your TCP sessions inside wireguard if you reconnect fast enough.Looking at it this morning I was reading that one peer can have several endpoints within its local config with a unique wireguard lan address to be accessed by.
Code: Select all
# wg show
interface: wg
public key: [...]
private key: (hidden)
listening port: 40874
fwmark: 0xca6c
peer: [..]
endpoint: [...]:45089
allowed ips: 0.0.0.0/0 <--- here it is. wireguard accepted 0.0.0.0/0
latest handshake: 31 seconds ago
transfer: 156 B received, 32.00 KiB sent
persistent keepalive: every 20 seconds
Set correct routes with ip route.OPENVPN sends all Internet traffic through the tunnel and yet can send local traffic (printers, other machines in my home WiFi private network 192.168.x.x) correctly within the home network. How can I do that with wireguard?
(a) Apparently 0.0.0.0/0 does NOT work, but 0.0.0.0/1 DOES indeed work.[/quote]## remote server (linode)
jgklinux /etc/wireguard # cat wg0.conf
[Interface]
ListenPort = nnnn
PrivateKey = [...]
Address = 10.8.0.1/32
[Peer]
PublicKey = [gibberish-1]
AllowedIPs = 10.8.0.2/32
## local peer (filet)
andraslinux /etc/wireguard # cat wg0.conf
[Interface]
Address = 10.8.0.2/32
ListenPort = nnnn
PrivateKey = [...]
[Peer]
PublicKey = [gibberish-2]
Endpoint = <my server public ip>:nnnn
PersistentKeepalive = 20
allowedIPs = 0.0.0.0/1, 10.8.0.1/32
I'm sorry, I'm not experienced enough in ip commands and routing and therefore I cannot understand the above difference,# with wireguard:
janos@andraslinux ~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 128.0.0.0 U 0 0 0 wg0
0.0.0.0 192.168.72.139 0.0.0.0 UG 3006 0 0 wlan0
10.8.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 wg0
192.168.72.0 0.0.0.0 255.255.255.0 U 3006 0 0 wlan0
janos@andraslinux ~ $
# with OVPN:
janos@andraslinux ~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 192.168.72.139 0.0.0.0 UG 3006 0 0 wlan0
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
128.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
192.168.72.0 0.0.0.0 255.255.255.0 U 3006 0 0 wlan0
<my server public ip> 192.168.72.139 255.255.255.255 UGH 0 0 0 wlan0
# w/o tunneling (OVPN or wireguard):
janos@andraslinux ~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.72.139 0.0.0.0 UG 3006 0 0 wlan0
192.168.72.0 0.0.0.0 255.255.255.0 U 3006 0 0 wlan0
Code: Select all
[Interface]
Address = 10.8.0.2/32
PrivateKey = <your client private key>
DNS = <your dns server of choice>
[Peer]
PublicKey = <your public key>
Endpoint = <your server ip/hostname>:<wireguard server port>
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 21
andraslinux /etc #
andraslinux /etc/wireguard # wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.8.0.2/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] wg set wg0 fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] iptables-restore -n
iptables-restore v1.8.7 (legacy): iptables-restore: unable to initialize table 'raw'
Error occurred at line: 1
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
[#] ip -4 rule delete table 51820
[#] ip -4 rule delete table main suppress_prefixlength 0
[#] ip link delete dev wg0
andraslinux /etc/wireguard #
this is the issue, not 0.0.0.0/0 since a few lines before the route was set correctly![#] iptables-restore -n
iptables-restore v1.8.7 (legacy): iptables-restore: unable to initialize table 'raw'
Error occurred at line: 1
Try `iptables-restore -h' or 'iptables-restore --help' for more information.