How to become gateway using a linux OS

From old notes..

Describe namran/how to become gateway here. sometime we have only one internet access but would like to have more than one device / computer/ laptop to share that same connection.

assume the one that will become gateway is a linux. kernel 2.6.* above.

enable ip forward. as root.

echo 1 > /proc/sys/net/ipv4/ip_forward

if want permanent change in /etc/sysctl.conf

and change the line that says net.ipv4.ip_forward = 0 to

net.ipv4.ip_forward = 1.

and..

using iptables ..

export OUT=ppp0
export IN=eth0
/sbin/iptables -t nat -A POSTROUTING -o $OUT -j MASQUERADE
/sbin/iptables -A FORWARD -i $OUT -o $IN -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i $IN -o $OUT -j ACCEPT

and from the other pc.. define the gateway ip.. as in eth0 in this case.

Related Post

2 Responses

  1. ahstod says:

    I have the same issue with eeebuntu on eeepc too, sudo this, sudo that.

    And feels weird typing my own password instead of root’s.

    what to do, stuck with centos/rhel for work … and since use the work machine so much, might as well make the other home machines the same for familiarity (except for the eeepc, for which the default centos is a bit too slow).

    Reply
  2. HawkEYE says:

    that remind me on one event at one of my project site.
    requirement was easy..
    “need to set a new ip address to the machine.”

    and the machine happened to be running Ubuntu 7.10 (Gutsy Gibbon) because someone else already installed it earlier..

    First few minute wasted to guess the root password as the one who installed it also not quite familiar..

    then only realized it need normal user password instead of root password.. (one of occupational hazard i think.)

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *