Setup Linux as an internet gateway

Setup Linux as an internet gateway

Setup Linux as an internet gateway 150 150 Roderick Derks

Needed:

  • Computer (Virtual is an option)
  • 2 NIC's
  • ADSL modem
  • linux and iptables

# vi /etc/sysconfig/networking/devices/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
NETMASK=255.255.255.0
USERCTL=yes
PEERDNS=no
GATEWAY=eth0
TYPE=Ethernet
IPADDR=192.168.100.1

# service network restart

# rpm -q iptables
# yum install iptables
# lsmod | grep iptable_nat
# modprobe iptable_nat
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# service iptables save

Activate ip forwarding
# echo \"1\" > /proc/sys/net/ipv4/ip_forward

Edit configfile so the change you made above is still active after a reboot
# /etc/sysctl.conf
net.ipv4.ip_forward = 1

Check the /etc/sysctl.conf file for errors
# sysctl -p

Roderick Derks

Liefhebber van fietsen, van het oplossen van IT puzzels, en van het delen van informatie om anderen te helpen.

All stories by:Roderick Derks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Your Name (required)

    Your Email (required)

    Subject

    Your Message

      Your Name (required)

      Your Email (required)

      Subject

      Your Message