Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo home router
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
MarcusXP
Apprentice
Apprentice


Joined: 18 Apr 2007
Posts: 237
Location: Toronto, ON, Canada

PostPosted: Sun Aug 17, 2008 8:47 pm    Post subject: Gentoo home router Reply with quote

Hi guys,

I am trying to build a Gentoo router at home.
I've read he documentation available here: http://www.gentoo.org/doc/en/home-router-howto.xml , and I've done pretty much all the steps described.
I have my eth1 connected to the internet (takes the IP automatically) and eth0 is my LAN, which will have IP addresses allocated dynamically from my Gentoo box (I already done that, it is working).
So now I have eth1 taking IP by DHP from my cable modem/router, and eth0 is manually set to 192.168.0.1, and I am running DHCP server over eth0.
The last step would be to make NAT working..so the computers connected to the eth0 interface will have internet from my Gentoo box. This is where I am stuck.
Also, in this guide, I see some kernel options, but most of them I cannot find in my 2.6.25-r7 kernel..
In my case, do I need PPP support and all these other stuff, enabled in kernel ? If not, which ones to enable ?

Also, when setting up NAT by running the iptables commands, I get this error at the second command in that list:

Server ~ # iptables -t nat -F
iptables v1.4.0: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.


Thanks a lot,


This is the kernel config listed on the http://www.gentoo.org/doc/en/home-router-howto.xml

Code:
Networking options  --->
   [*] TCP/IP networking
      [*] IP: advanced router
   [*] Network packet filtering (replaces ipchains)
If you use 2.4.x, you have to enable the following for DHCP:
   [*] Socket Filtering

   IP: Netfilter Configuration  --->
      [*] Connection tracking (required for masq/NAT)
         [x] FTP protocol support
         [x] IRC protocol support
      [*] IP tables support (required for filtering/masq/NAT)
         [*] IP range match support
         [x] MAC address match support
         [*] Multiple port match support
         [*] Packet filtering
            [*] REJECT target support
            [x] REDIRECT target support
         [*] Full NAT
            [*] MASQUERADE target support
         [s] Packet mangling
            [s] MARK target support
         [x] LOG target support

   QoS and/or fair queueing  --->
      [s] QoS and/or fair queueing
         [s] HTB packet scheduler
         [s] Ingress Qdisc

   [a] PPP (point-to-point protocol) support
      [a] PPP filtering
      [a] PPP support for async serial ports
      [a] PPP support for sync tty ports
      [a] PPP Deflate compression
      [a] PPP BSD-Compress compression
      [a] PPP over Ethernet
Back to top
View user's profile Send private message
Xanadu
Guru
Guru


Joined: 10 Oct 2002
Posts: 335
Location: Hour West of Philly (USA)

PostPosted: Sun Aug 17, 2008 10:06 pm    Post subject: Reply with quote

MarcusXP wrote:
[*] Full NAT
[*] MASQUERADE target support


I've always built all iptables modules as modules and NAT has worked fine for me. Perhaps try that.
_________________
I'm not a prophet or a stone-age man
I'm just a mortal with potential of a super man

-David Bowie
Back to top
View user's profile Send private message
MarcusXP
Apprentice
Apprentice


Joined: 18 Apr 2007
Posts: 237
Location: Toronto, ON, Canada

PostPosted: Sun Aug 17, 2008 10:37 pm    Post subject: Reply with quote

Yep, I figured that out :)
I enabled everything it was in that table and I could find in kernel, I recompiled the kernel, reboot, and now I was able to run those commands.

However, I made a mistake, and I don't know how to undo ..

Code:
Code Listing 5.2: Setting up iptables

I ran:

iptables -I FORWARD -i ${LAN} -s 192.168.0.0/255.255.0.0 -j ACCEPT

instead of:

iptables -A FORWARD -i ${LAN} -s 192.168.0.0/255.255.0.0 -j ACCEPT


actually, I run the first one, and after I saw that I had -I instead of -A, i ran the correct command.
However, I think I messed up the things now.. can I "undo" that command ? Is it a file where these are saved, and I can delete something if I want to ?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54793
Location: 56N 3W

PostPosted: Sun Aug 17, 2008 10:48 pm    Post subject: Reply with quote

MarcusXP,

Is there a difference for you ?
-I means insert, with no position, at the top of the table
-A means append to the end of the table.

What does
Code:
iptables -L FORWARD
show?
That lists all the rules in the FORWARD table.

There is also a -D command, for delete, if you need it read
Code:
iptables --help
to get the syntax
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
MarcusXP
Apprentice
Apprentice


Joined: 18 Apr 2007
Posts: 237
Location: Toronto, ON, Canada

PostPosted: Sun Aug 17, 2008 11:02 pm    Post subject: Reply with quote

Code:
Server ~ # iptables -L FORWARD
Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  192.168.0.0/16       anywhere
DROP       all  --  anywhere             192.168.0.0/16
ACCEPT     all  --  192.168.0.0/16       anywhere
ACCEPT     all  --  anywhere             192.168.0.0/16
Back to top
View user's profile Send private message
MarcusXP
Apprentice
Apprentice


Joined: 18 Apr 2007
Posts: 237
Location: Toronto, ON, Canada

PostPosted: Sun Aug 17, 2008 11:09 pm    Post subject: Reply with quote

I did everything in that tutorial.. but it doesn't seem to be working. From a computer connected to eth0, I cannot ping outside (yahoo.com for example). I can ping to my computer, but not outside.. so I didn't setup iptables properly, it seems.

Moreover, I think I have a problem with my ISP (or my home router or something) - when I plug some computers, internet stops working.. it is a random thing.. if I unplug the last computer from the network, internet comes back again.. maybe they have a limit of 4 or 5 computers in their routers ? My ISP is Bell (Canada) and I have a Linksys DSL modem/router.
Back to top
View user's profile Send private message
MarcusXP
Apprentice
Apprentice


Joined: 18 Apr 2007
Posts: 237
Location: Toronto, ON, Canada

PostPosted: Sun Aug 17, 2008 11:14 pm    Post subject: Reply with quote

My iptables rules..

Code:

Server ~ # vi /var/lib/iptables/rules-save

# Generated by iptables-save v1.4.0 on Sun Aug 17 18:49:34 2008
*nat
:PREROUTING ACCEPT [2896:383557]
:POSTROUTING ACCEPT [352:22539]
:OUTPUT ACCEPT [827:52893]
[528:37146] -A POSTROUTING -o eth1 -j MASQUERADE
COMMIT
# Completed on Sun Aug 17 18:49:34 2008
# Generated by iptables-save v1.4.0 on Sun Aug 17 18:49:34 2008
*mangle
:PREROUTING ACCEPT [1337906:183236594]
:INPUT ACCEPT [8603:7778313]
:FORWARD ACCEPT [1326490:175086954]
:OUTPUT ACCEPT [8192:1324557]
:POSTROUTING ACCEPT [1334642:176408550]
COMMIT
# Completed on Sun Aug 17 18:49:34 2008
# Generated by iptables-save v1.4.0 on Sun Aug 17 18:49:34 2008
*filter
:INPUT ACCEPT [5090:4199238]
:FORWARD DROP [42:3618]
:OUTPUT ACCEPT [5056:807079]
[8:788] -A INPUT -i lo -j ACCEPT
[115:13415] -A INPUT -i eth0 -j ACCEPT
[2:656] -A INPUT -i ! eth0 -p udp -m udp --dport 67 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -i ! eth0 -p udp -m udp --dport 53 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -i eth1 -p tcp -m tcp --dport 22 -j ACCEPT
[0:0] -A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
[0:0] -A INPUT -i eth0 -p tcp -m tcp --dport 0:1023 -j DROP
[0:0] -A INPUT -i eth0 -p udp -m udp --dport 0:1023 -j DROP
[1326448:175083336] -A FORWARD -s 192.168.0.0/16 -i eth0 -j ACCEPT
[0:0] -A FORWARD -d 192.168.0.0/16 -i eth0 -j DROP
[0:0] -A FORWARD -s 192.168.0.0/16 -i eth0 -j ACCEPT
[0:0] -A FORWARD -d 192.168.0.0/16 -i eth0 -j ACCEPT
COMMIT
# Completed on Sun Aug 17 18:49:34 2008
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54793
Location: 56N 3W

PostPosted: Sun Aug 17, 2008 11:18 pm    Post subject: Reply with quote

MarcusXP,

I cheat. I use Smoothwall on a dedicated system for a home firewall so I don't play with iptables directly unless I need something odd.
Smoothwall is a network appliance - it takes over the system you install it on and thats all it does.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
MarcusXP
Apprentice
Apprentice


Joined: 18 Apr 2007
Posts: 237
Location: Toronto, ON, Canada

PostPosted: Sun Aug 17, 2008 11:24 pm    Post subject: Reply with quote

Well I want to learn Gentoo, and this is one step.. :D

Also, I noticed that when I plug the network cable in the second NIC (the "LAN" one, that I running DHCP over it, and I want to give internet to), my internet goes down right away.
I can ping my DSL modem/router, but I don't have internet anymore, and also no one connected to my DSL modem/router..
How can my modem/router "know" when I plugged a cable in another network card in my computer ? This is odd ...
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54793
Location: 56N 3W

PostPosted: Sun Aug 17, 2008 11:36 pm    Post subject: Reply with quote

MarcusXP,

Your ISP can detect your use of NAT but they probably don't bother.
Maybe your NAT is not set up properly and unrouteable packets with destination addresses in the 192.168.x.x range are being sent to your ISP.
Thats not supposed to happen and they will be dropped by your ISP, however, your ISP may choose to drop all your traffic while the unroutable packets appear.

To see whats happening on your interfaces you need tcpdump or one of its look alikes. This is a packet 'sniffer' it will capture all of the traffic on an interface of your choice, so you can see what is coming and going.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum