November 24, 2024, 05:00:22 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: DSL/cable modem nat question  (Read 8002 times)

Offline raidmaxx

  • Linux Noob !
  • *
  • Posts: 4
DSL/cable modem nat question
« on: November 10, 2004, 05:50:56 AM »
This probably belongs in the "internet sharing in linux /NAT how-to" post but I'm not sure.. I have DSL internet service and I want to use my redhat linux 9 box as a router for my network. It has two ethernet cards in it and it is already configured for DHCP. I can get it to give my other computers on my network an IP address but for some reason I cant get it to act as a firewall and share its internet connection with the other computers on my network. I tried modifying and using the scripts you have in the NAT how-to and its still not working. Will I have to recompile my kernel to get this to work? Or is there a way to use the kernel included with a fresh installation of redhat 9 to do NAT? I do not have the latest kernel installed in my redhat box. Any help you can give me would be great.

Thanks
Daniel
R@1D/\/\@XX (raidmaxx)

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
DSL/cable modem nat question
« Reply #1 on: November 11, 2004, 06:53:57 AM »
well..  you can try squid if your NAT is not working.. but according to me you are doing some minor mistake, well you don't have to recompile the kernel as NAT is supported in it all the time. I suggest you to start from scratch ie try again.

Offline raidmaxx

  • Linux Noob !
  • *
  • Posts: 4
its still driving me crazy...
« Reply #2 on: November 30, 2004, 05:43:44 AM »
I still havent got NAT to work in redhat 9.. I havent recompiled the kernel, I went over my config with a fine tooth comb so to say, and I still havent gotten it to work.. is there any way you could maybe email or PM me what I need to know about NAT under redhat 9 with the original kernel that comes with RH9? my email address is dwestep@mikrotec.com  . any help I can get will be greatly appreciated...  Heres my configuration.. eth0 - ip= 192.168.1.18, subnet 255.255.255.0, gateway and dns= 192.168.1.1 eth1 - ip= 192.168.0.1 , subnet 255.255.255.0, no gateway, this is the interface I want handing out IP'd to the network.. I've managed to put together a DHCPD.conf file that actually works and hands out IP's, but I took the script designed for dialup use that tells the OS to forward packets from device ppp0 to eth0 and modified it to basically tell the OS to forward packets from eth0 to eth1 and it wont.. it wont forward requests from the machines internal to my lan to the outside internet.. I know the IP addresses I'm using indicate that I'm using another router, but I'm not, I just dont want to use my real IP's and I decided to use this in the place of my real IP. Can you please help me before I go nuts.. I'm about fairly new to the world of linux, I've been a faithful windows user for the past 5 years and decided to dabble with linux a bit for its security it offers...
Am I at least part way correct in what I'm doing just for the NAT part?? I plan to add in firewall scripts later to the server so it wont get hacked or DOS'ed on the internet. I just need my box to forward information from one IP/network card to the other and thats all.. I'll add in the firewall scripts later..  can you help me or tell me where to find help for this???
thank you
Daniel

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
DSL/cable modem nat question
« Reply #3 on: November 30, 2004, 05:34:38 PM »
well..

I know you have tried to explain as much  as u can but I think i am not able understand what you want .
But for sure the default RH9 kernel don't need to be recompile to do NAT.

You are having DSL.. now you want to share it with network !! is that so !
Sorry I am confused !

Offline raidmaxx

  • Linux Noob !
  • *
  • Posts: 4
Got it :-)
« Reply #4 on: December 01, 2004, 06:00:58 AM »
Yes, that is what I was wanting.. to use my linux box to share my connection with the network.. however after browsing this site more and customizing some code, I finally got it.. it works :-) THANK YOU for a wonderful site :-)

Daniel
aka. raidmaxx

Offline raidmaxx

  • Linux Noob !
  • *
  • Posts: 4
heres how....
« Reply #5 on: December 01, 2004, 06:42:52 AM »
This is what I managed to get to work for me finally.. I hope this helps somebody else because it sure worked for me.. All you need to do is plugin your IP addresses and this will work for you..

**keep in mind, eth0 is the card facing the internet and eth1 is for the internal network**

Create rc.nat file with the following contents:::

iptables=/sbin/iptables


iptables --flush -t nat

echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig eth1 192.168.1.18 netmask 255.255.255.0 up
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
ifup eth1

ok.. now use terminal and do chmod 755 on this file - chmod 755 /etc/rc.d/rc.nat
This makes the file executable..
now you'll need to edit your /etc/rc.d/rc.local file to say /etc/rc.d/rc.nat  
this will cause rc.nat to load the above code /\  /\
This is what forwards packets from the local network out to the internet and back to the appropriate machine..

Now, you need to activate IPTABLES. This can be done by going to /proc/sys/net/ipv4/ then find the file called ip_forward . Write a "1" to this file then save it. The next thing I did was to go to /etc/sysctl.conf and write a "1" to the line that says net.ipv4.ip_forward. this activates forwarding.. save and close this file with the "1" written to this line.

Now lets move on to the DHCP server half...

you will need to make a dhcpd.conf file in the /etc directory with this code in it :::

ddns-update-style ad-hoc;
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
option subnet-mask 255.255.255.0;
option domain-name "e2kcomputing.net";
option domain-name-servers 192.168.0.1,192.168.1.1;
option time-offset -1800;
subnet 192.168.0.0 netmask 255.255.255.0{
range 192.168.0.1 192.168.0.150;
}
default-lease-time 600;
max-lease-time 7200;

You will also need a dhcpd.leases file located in the /var/lib/dhcp do a makefile /var/lib/dhcp/dhcpd.leases and this will create the leases file..
With this configuration, you get NAT and a DHCP server, all in one. If you just want static nat just use the first half of my directions and leave off the dhcp part.. However I think dhcp makes configurations easier..

This should be everything you need to do NAT under linux..
if you have any problems, let me know...