All pastes #249823 Raw Edit

Someone

public text v1 · immutable
#249823 ·published 2006-11-16 05:39 UTC
rendered paste body
# Configuration on the gateway:
#eth0 to external network (WAN)
#eth1 to internal network (LAN)

# Probably already set by ISP
ifconfig eth0 XXX.XXX.XXX.XXX netmask 255.255.255.0 broadcast XXX.XXX.XXX.255
# ifconfig eth1 192.168.10.101   will probably set the rest correctly by default
ifconfig eth1 192.168.10.101 netmask 255.255.255.0 broadcast 192.168.10.255

# Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward             # Enables packet forwarding by kernel


# (didn't need this for only one box, in my experience)
# Create a route for internal packets:
route add  -net 192.168.10.0  netmask 255.255.255.0 gw XXX.XXX.XXX.XXX dev eth1


# On the client, add the gateway as the default gateway
# Something like:
route add default gw <hostname>
ifconfig eth0 192.168.10.102