RxBrad

Sample WireGuard config - Oracle VCN Host & Local Docker Client

Feb 3rd, 2023
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. Oracle - /etc/wireguard/wg0.conf
  2. ================================
  3. [Interface]
  4. PrivateKey = xxx
  5. ListenPort = 55108
  6. Address = 10.0.0.1/24
  7.  
  8. PostUp = iptables -t nat -A PREROUTING -p tcp -i ens3 --match multiport --dports 32400 -j DNAT --to-destination 10.0.0.2
  9. PostUp = iptables -t nat -A POSTROUTING -o ens3 -j SNAT --to-source 10.0.0.151
  10.  
  11. PostDown = iptables -t nat -D PREROUTING -p tcp -i ens3 --match multiport --dports 32400 -j DNAT --to-destination 10.0.0.2
  12. PostDown = iptables -t nat -D POSTROUTING -o ens3 -j SNAT --to-source 10.0.0.151
  13.  
  14. [Peer]
  15. PublicKey = xxx
  16. AllowedIPs = 10.0.0.2/32
  17.  
  18.  
  19.  
  20. Local Docker - /config/wg0.conf
  21. ===============================
  22. [Interface]
  23. PrivateKey = xxx
  24. Address = 10.0.0.2/24
  25.  
  26. PostUp = DROUTE=$(ip route | grep default | awk '{print $3}'); HOMENET=192.168.0.0/16; HOMENET2=10.0.0.0/8; HOMENET3=172.16.0.0/12; ip route add $HOMENET3 via $DROUTE; ip route add $HOMENET2 via $DROUTE; ip route add $HOMENET via $DROUTE; iptables -I OUTPUT -d $HOMENET -j ACCEPT; iptables -A OUTPUT -d $HOMENET2 -j ACCEPT; iptables -A OUTPUT -d $HOMENET3 -j ACCEPT; iptables -A OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT
  27.  
  28. PreDown = HOMENET=192.168.0.0/16; HOMENET2=10.0.0.0/8; HOMENET3=172.16.0.0/12; ip route delete $HOMENET; ip route delete $HOMENET2; ip route delete $HOMENET3; iptables -D OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT; iptables -D OUTPUT -d $HOMENET -j ACCEPT; iptables -D OUTPUT -d $HOMENET2 -j ACCEPT; iptables -D OUTPUT -d $HOMENET3 -j ACCEPT
  29.  
  30.  
  31. [Peer]
  32. PublicKey = xxx
  33. AllowedIPs = 0.0.0.0/0
  34. Endpoint = [Oracle public IP address]:55108
  35. PersistentKeepalive = 25
Advertisement
Add Comment
Please, Sign In to add comment