LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-30-2005, 03:13 AM   #1
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Rep: Reputation: 30
How to enable ip forwarding (to make a simple router)


Hello everybody,

I have a FC3 desktop.
I want to use it for very simple routing. It is easy to give a few network commands and do it. But the problem is that the ip forwarding is not enabled in the kernel (the first number on the second line of the file /proc/net/snmp is "0" - Am I right in this interpretation ?). Without enabling this the system will not forward ip packets from one interface to another.

How can I enable this ?

Can any of the gurus (or gurus-in-waiting) guide me in this ?


Thanks in advance.



Prabhat Soni
 
Old 03-30-2005, 03:19 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
The simplest way is:
Code:
echo "1" > /proc/sys/net/ipv4/ip_forward
Regards
 
Old 03-30-2005, 03:42 AM   #3
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Original Poster
Rep: Reputation: 30
Thanks Mr. Bathory

This should work. I will try and let you know.

I will tell you what I am trying to do, though.

At present I am accessing internet from my home PC through a squid server on a laptop. My home PC is connected to the laptop-squid through eth. The problem with this set is that I am able to do surfing/browsing only. I want to listen to online news with real player -I cannot do. I want to play online games -I cannot do.
My first query is: Is it possible to undertake both the activities with the existing set up.

I Feel that if I configure my laptop as a mini router between my home PC on one hand and the PPP interface (to internet) on other hand, and then in my home PC, declare the laptop as the default gateway - I should be able to play online games, listen to online news, etc etc. My second query is simple: Am I right in believing so.


Thanks again for the useful suggestion.



Prabhat Soni

Last edited by prabhatsoni; 03-30-2005 at 03:43 AM.
 
Old 03-30-2005, 06:19 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You're right.
You must configure your laptop as a router/firewall to allow outgoing traffic and block unwanted incoming traffic.
It's possible though to setup squid for other protocols such as real-audio etc. But the first solution is more secure.

Regards
 
Old 03-30-2005, 09:39 AM   #5
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Original Poster
Rep: Reputation: 30
Thanks once again.

Now It is not working.
The setup:
Laptop with squid -eth0- 192.168.168.2
PC -eth0 - 192.168.168.1
Laptop -ppp0- 142.62.32.3
ISP - ppp0 address -142.62.32.19

Next - I gave command echo "1" > /proc/sys/net/ipv4/ip_forward

Then added default route in my home PC:
route add -net default eth0

With this set up I should be able to ping 142.62.32.19 - But I am not.
I can ping ppp0 interface 142.62.32.3 - implying that the default route created in the pc is ok.
I need not mention that I can ping the eth0 interfaces (from both ) of each other, and that I can browse internet from both the nodes - the possibility of network being down is not there.

Laptop kernel routing table:
Code:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
142.62.32.19     0.0.0.0         255.255.255.255   UH    0     0      0    ppp0
192.168.168.0   0.0.0.0          255.255.255.252   U     0     0      0    eth0
169.254.0.0     0.0.0.0          255.255.0.0       U     0     0      0    lo
0.0.0.0         142.62.32.19     0.0.0.0           UG    0     0      0    ppp0
Code:
PC kernel routing table:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.168.0   0.0.0.0         255.255.255.252 U      0      0      0   eth0
0.0.0.0         0.0.0.0         0.0.0.0         U      0      0      0   ppp0
Only possiblity - the ip forwarding is not working !!!

Am I missing out on something ? In the simplest of the configuration as above this should work.


Prabhat Soni

Last edited by prabhatsoni; 01-22-2007 at 11:59 PM.
 
Old 03-30-2005, 10:07 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Run:
Code:
route add default gw 192.168.0.2
at your PC to set your laptop as a gateway and test again using "traceroute" to see if you reach gateway and how the packets are routed.

Regards
 
Old 03-30-2005, 10:22 AM   #7
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Original Poster
Rep: Reputation: 30
Thanks a lot,

I did what you suggested.

In the traceroute I find that the packet is indeed reaching the gateway (the laptop - 192,168.168.2). But after that it is all starts - A lot of stars.

How to go about it now ?


Prabhat Soni
 
Old 03-30-2005, 10:52 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
That's normal if your ISP block ICMP packets. Use a browser to see if you can visit any sites.
 
Old 03-31-2005, 08:44 AM   #9
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Original Poster
Rep: Reputation: 30
Hello Mr. Bathory

My ISP is not blokcing ICMP packets, becasue I can give "traceroute yahoo.com" from my laptop and get the trace.
Nevertheless I tried to browse, but the browser kept on saying "loading..." and then timed out.

I tried one more thing:
I ran the named server named on my laptop and made appropriate entries in the PC's resolv.conf (nameserver 192.168.168.2 - first entry). Then I gave command " dig yahoo.com". This too timed out.

I feel this is indicative of deeper malaise.

What could be the reason. My packets are reaching the laptop. It is implied by the fact that the browser timed out rather than giving some other message. Also, the the first hop in the traceroute is the laptop. There seems to be only one reason - The ip forwarding is not working.
I checked the first number on the second line of the file /proc/net/snmp, and found it to be 1 indicating that the ip forwarding is enabled.

Is there any way by which I can check the ip forwarding in the laptop.

Prabhat Soni
 
Old 03-31-2005, 12:56 PM   #10
frgtn
LQ Newbie
 
Registered: Mar 2005
Location: Kaunas, Lithuania
Distribution: Slackware 10.1
Posts: 28

Rep: Reputation: 15
Hello
I don't know how did you configure your firewall, but there is a good howto on that subject here:
http://en.tldp.org/HOWTO/IP-Masquerade-HOWTO/
I hope it helps
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 12:08 PM
iptables on router: simple port forwarding not working hamish Linux - Networking 1 10-27-2005 06:06 AM
how to enable port forwarding linetnew Linux - Networking 1 05-26-2005 04:20 AM
How to enable packet forwarding davidho3 Linux - Networking 2 10-12-2004 10:45 AM
Simple mail forwarding? zymurgist Linux - Networking 1 03-24-2004 06:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration