General discussion

Locked

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 10.10.10.10 inteface and a 172.16.172.16 interface with the first being your default. Say you want all traffic destined for 200.200.0.0/16 to go to 172.16.172.15 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 200.200.0.0 -netmask 255.255.0.0 172.16.172.15). Now it will go out your 172.16.172.16 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 sgt_shultz In reply to how to make linux as a ro ...

www.linuxrouter.org

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 1.2.3.4.
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4

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

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


Masquerading

Collapse -

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

try

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

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

net.ipv4.ip_forward=1

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

Mahesh

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

ELSE

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