I read another thread Routing Port Forwarding about something close to what i'm doing, but it doesn't quite work for me and I tried quite hard to read the documentation. I'm almost certain I have my system properly configured, but maybe I'm missing something?
I would like to, at the least, allow people on the internet to use a bounce VPS wireguard server provisioned with alpine, along with a dedicated openwrt router on my LAN, to access a service on tcp port 5555 on a lan system. I have not been able to successfully achieve this yet.
Router:
root@OpenWrt:~# wg
interface: WIREGUARD
public key: <key>
private key: (hidden)
listening port: 59538
peer: <another key>
endpoint: <vps ip>:27479
allowed ips: 10.100.1.0/24
latest handshake: 29 seconds ago
On the openWRT router, provisioned via the GUI:
in wireguard peer:
route allowed ip's is checked
in firewall:
there are two firewall zones, one for wireguard, one for lan.
accept: input, output, forward. No masquerading or rules.
alpine:~# wg
interface: wg0
public key: <key>
private key: (hidden)
listening port: 27479
peer: <another key>
endpoint: <residential outfacing IP>:59538
allowed ips: 192.168.1.0/24, 10.100.1.0/24
latest handshake: 40 seconds ago
alpine:~# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 <vps ip> 0.0.0.0 UG 0 0 0 eth0
10.100.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
<vps ip> 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
in sh script executed on postup:
#!/bin/bash
iptables -I INPUT -i eth0 -p udp --dport 27479 -j ACCEPT #wireguard proto accept
iptables -I FORWARD -i eth0 -o wg0 -j ACCEPT #allow forwarding traffic
iptables -I FORWARD -i wg0 -j ACCEPT #allow the reverse also
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t filter -A FORWARD -m conntrack --ctstate DNAT,ESTABLISHED,RELATED -j ACCEPT #permit existing sockets
iptables -t nat -I PREROUTING -p tcp --dport 5555 -j DNAT --to-destination 192.168.1.112
Do I have this configured correctly? What am I missing?
since some pro users may expect me to include this, below this line is some of the conf files from UCI:
uci export network
package network
config interface 'loopback'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
option device 'lo'
config globals 'globals'
option ula_prefix 'fd7d:bd3c:35d8::/48'
config interface 'lan'
option proto 'static'
option netmask '255.255.255.0'
option delegate '0'
option force_link '0'
option ipaddr '192.168.1.100'
option gateway '192.168.1.1'
option device 'br-lan'
list dns '8.8.8.8'
list dns '8.8.4.4'
config device 'lan_eth1_1_dev'
option name 'eth1.1'
option macaddr '8c:59:73:fe:49:5e'
config device 'wan_eth0_2_dev'
option name 'eth0.2'
option macaddr '8c:59:73:fe:49:5f'
config switch
option name 'switch0'
option reset '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '0 6t 1 2 3 4 5'
option vid '1'
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0.2'
list ports 'eth1.1'
config interface 'WIREGUARD'
option proto 'wireguard'
option private_key '<key>'
option mtu '1420'
option delegate '0'
list addresses '10.100.1.2/32'
config wireguard_WIREGUARD
option description 'vps'
option public_key '<peer key>'
option endpoint_host '<vps host'
option endpoint_port '27479'
option persistent_keepalive '23'
option route_allowed_ips '1'
list allowed_ips '10.100.1.0/24'
config device
option name 'WIREGUARD'
option mtu '1420'
option ipv6 '0'
uci export firewall
package firewall
config defaults
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option synflood_protect '1'
option flow_offloading '1'
option flow_offloading_hw '1'
config include
option path '/etc/firewall.user'
config include 'miniupnpd'
option type 'script'
option path '/usr/share/miniupnpd/firewall.include'
option family 'any'
option reload '1'
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
config zone
option name 'wg'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'WIREGUARD'
config forwarding
option src 'lan'
option dest 'wg'
config forwarding
option src 'wg'
option dest 'lan'