Saturday, December 28, 2019

Adding a new machine as default gateway

1) Enable IP forwarding (server machine)
# echo 1 > /proc/sys/net/ipv4/ip_forward

To make the change permanent insert or edit the following line in edit /etc/sysctl.conf:
net.ipv4.ip_forward = 1

2) Iptables initial settings (server machine)
# iptables -F
# iptables -t nat -F
# iptables -t mangle -F
# iptables -X

3) Forward/Masquerade (server machine)
# iptables -A POSTROUTING -s -o tun+ -j MASQUERADE -t nat
# iptables -I FORWARD -s -j ACCEPT
# iptables -I FORWARD -d -j ACCEPT

4) In the client machine, add the new default gateway
# ip route del default
# ip route add default via

No comments:

Post a Comment