LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   linux routing (https://www.linuxquestions.org/questions/linux-newbie-8/linux-routing-4175472390/)

jeammy 08-06-2013 06:40 PM

linux routing
 
pls help me out, how to set up routing on linux server

Ser Olmy 08-06-2013 07:14 PM

Easy.
  1. Enable routing (the exact procedure varies from distribution to distribution, but in the end it all boils down to writing a "1" to /proc/sys/net/ipv4/ip_forward)
  2. Add/remove routes from the routing table (with ip route add <network>/<prefix> via <gateway> or route add -net <network>/<prefix> gw <gateway>)
  3. Optional: Install a routing daemon like Quagga or Bird and set up a routing protocol
If you want more specific advice, you'll need to ask a more specific question.

SAbhi 08-06-2013 11:18 PM

To permanently set ip forwarding do this:

Code:

vi /etc/sysctl.conf
net.ipv4.ip_forward = 1    #change the value from 0 to 1, save and exit

sysctl -p /etc/sysctl.conf  #run this command so that it can read the updated sysctl.conf file

service network restart  # restart the network service


prayag_pjs 08-07-2013 10:07 AM

You can configure Linux Box as a router using below scenario :

1. PC/Server with two lan cards.
Code:

i.eth1=>conteting internal LAN 192.169.10.xxx
 ii.eth0=>connecting Internet i.e external network (Here your public IP is connected ex: 68.68.2.1)

2.Set IP forwarding :
Code:

#vi /etc/sysctl.conf:
net.ipv4.ip_forward = 1

To enable the changes made in sysctl.conf you will need to run the command:
Code:

sysctl -p /etc/sysctl.conf
3.configure IPTABLES to allow routing

Code:

iptables -F
Code:

# iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
# iptables --append FORWARD --in-interface eth1 -j ACCEPT

Code:

iptables -L


All times are GMT -5. The time now is 12:31 PM.