General discussion


how to make linux as a router

By shazianaz13 ·
plz tell me step wise how can i make linux as a router

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by cpfeiffe In reply to how to make linux as a ro ...

As luck would have it IP Forwarding is enabled by default. So if you haven't turned off IP Forwarding and you haven't made any changes to your iptables that would prevent packets from entering/leaving the server/router you are pretty much good to go.

You will need at least two interfaces, obviously.

You will need to create a new start script (say /etc/init.d/routes with a link to /etc/rc2.d/S75routes or something similar). In that start script you can define all of the traffic you want to go to a device connected to your non-default interface.

For example say you have a inteface and a interface with the first being your default. Say you want all traffic destined for to go to next (as it leaves your box). The default route won't work here so you will define this in your routing script (route add -net -netmask Now it will go out your interface adn find ".15" with no problem since it is local to that interface.

In summary, you need at least two interface, IP Forwarding enabled (default), properly configured iptables (depends on how you installed/configured it) and a routing script that will run at boot time to define your routes.

Good luck.

Collapse -

by subhashanarayan In reply to how to make linux as a ro ...

which version of linux. If it is 8.0 use iptables

You want to do Source NAT; change the source address of connections to something different. This is done in the POSTROUTING chain, just before it is finally sent out; this is an important detail, since it means that anything else on the Linux box itself (routing, packet filtering) will see the packet unchanged. It also means that the `-o' (outgoing interface) option can be used.

Source NAT is specified using `-j SNAT', and the `--to-source' option specifies an IP address, a range of IP addresses, and an optional port or range of ports (for UDP and TCP protocols only).

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

## Change source addresses to
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to

## Change source addresses to, or # iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to

## Change source addresses to, ports 1-1023 # iptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT --to


Collapse -

by jackup_in In reply to how to make linux as a ro ...


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

If you want it to happen after a reboot edit /etc/sysctl.conf


Should be default of 0, needs to be 1 for a firewall/router.


Collapse -

by dillip_linux In reply to how to make linux as a ro ...

How many network interfaces do you have?

If you have only eth0 then...

echo "1" > /proc/sys/net/ipv4/conf/eth0/proxy_arp


Pass the value

echo "1" > /proc/sys/net/ipv4/conf/all/proxy_arp

for all interfaces

Back to Linux Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums