User Tools

Site Tools


ip_forwarding

This is an old revision of the document!


IP Forwarding

To enable a machine to act as a gateway for a network:

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE

Where 192.168.1.0/24 is the network which will use this machine as a gateway.

To make this permanent, on Debian/Ubuntu:

touch /etc/network/if-up.d/iptables
chmod 755 /etc/network/if-up.d/iptables

And add the following the new file:

#!/bin/bash

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE

For Red Hat/Fedora:

iptables-save

Good IP Tables Tutorial:

ip_forwarding.1171024443.txt.gz · Last modified: 2016/11/25 22:38 (external edit)