# Building a router

## leni07

Ok there are a lot of threads that kind of address this topic, but i feel i needed a few more specifics. OK i am looking to put together a router/http server. That is all i want it to do, at least for now. So i figured i would go through the install after that get webmin, shorewall, and after that i am a bit stuck. I want it to assign via dhcp, and possibly be a DNS (BIND does that i believe so i guess i woudl emerge that too)  But what else do i need, other than apache to get it up and running. What exactly would ahndle the dhcp stuff. I am looking for teh quick and dirty, nothign fancy just enough to work, lol. This is going to be a simple box no X, just shell because i figure i can use webmin form another computer to do everything  :Smile:  Well thanks for anyone who cna point me to a guide or offer a tip or anything.

----------

## Lajasha

Only 2 things I can see right off the start are you did not mention IP tables (for routing), as far as DHCP I think, If you dont already have it you can emerge -av dhcp and it should work for ya.

----------

## neomatrix35

hes installing shorewall so there is no need for iptables

----------

## Lajasha

 *neomatrix35 wrote:*   

> hes installing shorewall so there is no need for iptables

  Umm last time I knew shorewall was just an easy interface for iptables.

As an old tv show once said "don't take my word for it check it out":

http://www.shorewall.net/

Take note as to what the banner says.

----------

## neomatrix35

meh... what do i know...i run iptables from the command line/scripts... so i dont know any other way of implementing firewalls to a linux system

----------

## RedDawn

 *neomatrix35 wrote:*   

> meh... what do i know...i run iptables from the command line/scripts... so i dont know any other way of implementing firewalls to a linux system

 

Owned!!   :Twisted Evil: 

----------

## leni07

yeah shorewall is an interface to iptables but it will install iptables...so whatever lol. Ok so i need to set up the dchpd server but what about a NAT do i need to set that up, and if i do how do i set oen up lol.

----------

## nobspangle

Shorewall will take care of all your NAT, routing and firewall stuff by configuring iptables. You'll want dhcp for the dhcp server and it goes hand in hand with bind, so if you want a DNS server I'd use that. Then you just need apache for your webserver, you may also want mod_php if you're going to use server-side scripting.

----------

## leni07

great ok thanks....Now im off to install gentoo see you in 3 days lol...actually ot cause i think i will be alzy and use stage 3 lol thanks everyone

----------

## leni07

ok well actually i think i have a problem. I have installed base system and kernel etc...i booted and i was unable to get a IP from DHCP on my external NIC. I wonder, i have dsl (username and password) what do i need to like get an auto login for that. do i need some adsl thing i have heard about something along thsoe lines. Because i cant get on the internet to emerge dhcp and iptables etc...i only have my base system. How can i have my box automatically login to my ISP without typing in a password or username every boot???? Is there a way, thanks

----------

## Jeremy_Z

How do you "manually" connect in gentoo ?

I assume you use pppoe, then pppd should take care of the connection. You may find some howto in this forum about it.

----------

## leni07

that is just the thing, i have never manually connected with gentoo...my netgear router has always handled that, and then my box connected to my router, but since this new homemade router is going to replace the netgear i needed some kind of login thing. And yes thanks after some searching it seems ppp is the answer.

----------

## leni07

OK well i have the dsl connection working, dhcp, iptables, shorewall, webmin are emerged. But i cannot start dhcp, it doesnt say why it just doesnt start, i dont know where the log is for it, now here si my dhcp.conf i dont need much, just to provide addresses to my client comps, on a 10.0.0.1 network *Quote:*   

> # Home
> 
> option broadcast-address 10.0.0.255;
> 
> option subnet-mask 255.255.255.0;
> ...

 

----------

## bennettp

You need to tell dhcpd which interface to listen on. I haven't used it since I had redhat, but i actually needed to hack the startup script and add the option manually. (i think it was -L eth0 or something).

Alternately, you can leave the script as it is (probably a good idea). dhcpd will listen on ALL interfaces, and you need to add empty subnet declarations in dhcpd.conf for every subnet that your computer is part of, but you don't want it to listen on. If that makes sense.

After editing dhcpd.conf, you can check if the conf works by just running "dhcpd". If it starts, good. If it doesn't, fix whatever was wrong, and try again.

----------

## Jeremy_Z

Also did you look at dnsmasq ? I use it for DNS caching and it can act like dhcpd too.

----------

## leni07

OK well i did specify which interface in webmin. It listens n eth1 and eth0 is my external connection. I am not sure what you mean by empty subnets, and once again like i said i dont knwo how to check what went wrong with the startup to fix it, i dont know where to check the lods for dhcp. I dont think my netwrk has any other subnets, i only want to hvea 10.0.0.1 network that is it.

----------

## nobspangle

try adding

ddns-update-style adhoc;

at the beginning or the end of dhcp.conf.

----------

## bumpus

To get dhcpd working on the proper interface you need to configure the interfaces setting in /etc/conf.d/dhcp.

----------

## leni07

 *Quote:*   

> Author  	Message
> 
> bumpus 	
> 
> Posted: Wed Jul 14, 2004 11:34 am    Post subject:
> ...

 

well ok but 

 *Quote:*   

> # Home
> 
> option broadcast-address 10.0.0.255;
> 
> option subnet-mask 255.255.255.0;
> ...

 

i do not see an interfaces section in my dhcp.conf....that is the entire file those 7 lines[/list]

----------

## leni07

ok actually for now we can forget about dhcp if no one has an answer. Static IP's will be fine with me as long as they will work, but it seems they wont  :Sad:  I set them all static, (10.0.0.3-10.0.0.5) Questions how can i get the box to listen to that Ip for routing and such without dhcp, i figured i could use iptables but for some reaosn now when i try to start iptables it gives me and error, "could not find module ip_tables do you need to insmod. try iptables-restore -h for more details" I try iptables-restore but all it is is a bunch of options as comments. 

Basically what i need to know is simple, how to get 10.0.0.1 to act as a gateway, i know how to set my static ip computers to use 10.0.0.1 as a gateway but i dont knwo how to get it to act like a gateway.

PS one last thing if i have 2 NICs, eth0 and eth1. eth0 is hooked to the modem and recieves IP from dhcp. eth1 is hooked to a switch with other computers on it and has follwing config

eth1="10.0.0.1 broadcast 10.0.0.255 netmask 255.255.255.0"

#gateway=eth0/192.168.1.1

now do i need to set a gateway for eth1, or can i leave it blanks since IT IS a gateway for my network PC's. Is there anything else i need to set for eth1.  

And lastly i can ping all local computers when i have them hooked to gentoo router and switch, and i did change my DNS to 10.0.0.1 since i can get DNS straight from the ISP..i hope...maybe it is a DNS problem after all of this, does anyone know some good DNS servers i could use to test it. Because at least right now i really dont want to have to set up bind, i cnat even get a simple router working.

----------

## nobspangle

first off let's get your dhcp working

 *Quote:*   

> default-lease-time 21600;
> 
> max-lease-time 345600;
> 
> option subnet-mask 255.255.255.0;
> ...

 

 *ISC DHCP readme wrote:*   

> Make sure CONFIG_PACKET (Packet socket) and CONFIG_FILTER (Socket Filtering) are enabled in your kernel configuration

 

And then read what you have already been told  *Quote:*   

> To get dhcpd working on the proper interface you need to configure the interfaces setting in /etc/conf.d/dhcp

  This is not the dhcp.conf file it is /etc/conf.d/dhcp

Then for iptables you need to have several modules configured most important is ip_tables there is a full list here

----------

## leni07

Hey ok thanks for the help, i got DHCP working, it took a while because clearly i am dumb. Sorry about the confusion too with the different conf files. Well i unfortuanely still have a problem. Even tho dhcp now works and assigns addresses and everything, i cannot ping my router or reach the outside world when i try to ping from Windoz or linux it just times out. I am not sure why, clearly they can contact 10.0.0.1 because they get IP addresses, but they dont seem to be able to connect otherwise. But the router is online with rp-pppoe with masquerade set as firewall. I am wondering, i have not configured shorewall/iptables at all, but they do start at startup, could that be the issue, no rules therefore deny all traffic. I am not sure. I tried to disable them but that didnt help, but i remember seeing somewhere that when iptables is disabled it has a rule that it denys all traffic. I dont know. But anyway any ideas on the situation would be of great help as once again i am stuck so close to my goal.

PS i recompiled my kernel with ALL of thsoe things listed in the last post, even some extras just to make sure lol. So that is no longer an issue. Thanks for all your help everyone.

----------

## nobspangle

can you post ifconfig from one of your clients and from the router and also iptables -L from the router.

----------

## leni07

I have been trying to find a way to post my ifconfigs form workstations and router, only problem is i cant do it right because when the router is going i cant access the internet and with the router i have no graphical internet. So sadly i think i am going to have to scrap this idea because i dont know what the porblem is and i have no way to let you guys help me because the problem prevents me from posting information about the problem  :Sad:  Thanks everyone for all your help seriously you guys are awesome, i just wish i knew a little more and then maybe i could do it. But oh well thanks again

----------

## Jeremy_Z

You should not give up, or you will never learn.

run "iptables -L" in your router, that will print out the firewall rules.

also, you can emerge links which is a console web browser (can be useful) and test the connexion

----------

## depontius

 *leni07 wrote:*   

> I have been trying to find a way to post my ifconfigs form workstations and router, only problem is i cant do it right because when the router is going i cant access the internet and with the router i have no graphical internet. So sadly i think i am going to have to scrap this idea because i dont know what the porblem is and i have no way to let you guys help me because the problem prevents me from posting information about the problem  Thanks everyone for all your help seriously you guys are awesome, i just wish i knew a little more and then maybe i could do it. But oh well thanks again

 

Let's try something really basic. Did you remember to set /proc/sys/net/ipv4/ip_forward to "1", either with echo or /etc/sysctl? This one is obvious, but sometimes so obvious that it gets forgotten.

Out of curiousity, why don't you want to use your hardware router?

----------

## leni07

I flushed my iptable rules, made sure forwarding was set, /proc/sys/net/ipv4/ip_forward = 1, but now my rp-pppoe i have all osrts of problems, and nothing seems to be working. I dont want to give up but at least for now i just dont have the time you know, and i really appreciate everyting you guys have done but since i am not goign to be dedicated to this anymore i feel bad asking for help and possibly wasting your time. I am gunna keep poking around and see if i can fix it a little at a time, if it works i will let you guys know what did it in case someone ever has similar problems. Thanks again.

----------

## Jeremy_Z

Flush but don't forget to check the policies (should be accept)

Can you access the net from the router at least ? (with links f.e.)

----------

## leni07

OK wow well your never going to believe this, my problem was my DNS servers, my router gave option server as itself, however apparently it is not able to really transfer the servers form teh ISP to my client comps. I switched the option to my ISP's DNS specifically and now everything works fine. Such a dumb problem, sorry everyone i feel i wasted your time.

----------

