LinuxQuestions.org
Help answer threads with 0 replies.
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
 
LinkBack Search this Thread
Old 03-17-2010, 08:41 AM   #1
strycnine
Member
 
Registered: Jul 2006
Location: Romania
Distribution: Fedora 12
Posts: 160

Rep: Reputation: 31
dhcp server with two subnets


Hi, I'm trying to build a linux(fedora 12) dhcpd server(and gateway), that have 3 network cards(eth0 have with public ip, eth1 192.168.2.1 class and eth3 with 192.168.3.1 class).

Because I have just a switch, I want to put both cables(from eth1, eth2) in the switch.
Every client has 2 network card(eth0, eth1).
My question is, is there any way to conf eth0 to take from server ip from 192.168.2.1 class, and eth1 from 192.168.3.1?
The internet will work only on eth0.


my dhcpd.conf for now looks like this:

subnet 192.168.2.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option routers 192.168.2.1;
range 192.168.2.101 192.168.2.254;
}

subnet 192.168.3.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option routers 192.168.3.1;
range 192.168.3.101 192.168.3.254;
}

thx
 
Old 03-17-2010, 12:18 PM   #2
cardy
Member
 
Registered: Jan 2005
Location: Shropshire, England, UK
Distribution: RedHat, Fedora, CentOS..........
Posts: 121

Rep: Reputation: 19
Ok if I am understanding your setup then your asking a lot more than simple DHCP.

The DHCP options you have look good however if you want each client to have an IP on one of each of your internal networks (192.168.2.0 and 192.168.3.0) I believe you would either need separate switches or you will need to setup vLANs on the local switch so that you split the local LANs.

As far as your machines on the internal network talking to the internet you will need a few more things enabled before they can talk to the internet.

On the gateway machine you will need to enable IP routing, this can be done by the following command

Quote:
echo 1 > /proc/sys/net/ipv4/ip_forward
You can also set the above value on most RedHat style distributions in /etc/sysctl.conf by modifying the line

Quote:
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
and setting it to 1 then running

Quote:
sysctl -p
This will allow machines with IPs on the different subnets to logically talk to each other.

I am assuming your eth0 has a single IP from your ISP that allows it to talk to the Internet. To allow other machines on the local network to talk through to the net you will need to enable Network Address Translation (NAT) on the gateway machine so it masquerades the IP addresses of the machines on your local network.

A script similar to this will turn on the masquerade options in linux to allow the machines to talk through the gateway to the Internet. I should point out however that this script does not implement any firewall security for the local host and that if your planning on building a gateway you may first want to investigate some of the linux distributions that have the features you need but with firewall and other security measures included.

Quote:
#!/bin/sh

# Define External and Internal Interfaces.

EXT='eth0'
INT='eth1'
INT2='eth2'

# Ensure ip_forwarding is enabled.
echo 1 > /proc/sys/net/ipv4/ip_forward

# Clear the IP Tables, NOTE: This will flush ANY firewall rules you have in place already on the machine if you
# need your existing rules you will need to integrate the iptables commands to allow it.
echo Flushing IP Tables
/sbin/iptables -F

# Enable NAT (Masquerade) for the Internal interfaces to the external interfaces.
echo Setting up Masquerade

# Enable NAT
/sbin/iptables -t nat -A POSTROUTING -o $EXT -j MASQUERADE

# Enable the network eth1
/sbin/iptables -A FORWARD -i $EXT -o $INT -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i $INT -o $EXT -j ACCEPT

# Enable the network eth2
/sbin/iptables -A FORWARD -i $EXT -o $INT2 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i $INT2 -o $EXT -j ACCEPT

# Display the IP tables configuration
/sbin/iptables -L

# I have used a program called dnsmasq, this allows the gateway to accept DNS requests for clients on the local network
# and to proxy them to your ISP DNS servers so the internal clients are able to resolve IP's. Your internal clients would
# Need to point to the IP address of the gateway for their network for DNS/nameserver requests.

service dnsmasq restart

Last edited by cardy; 03-17-2010 at 12:20 PM. Reason: Add comment
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DHCP server having 2 subnets through 2 nics dils Linux - Newbie 2 05-21-2009 04:09 AM
Help with DHCP Failover server with multiple subnets Kolibri Linux - Server 0 05-04-2009 04:50 AM
DHCP Server for several subnets Simon_Sez Linux - Software 5 12-30-2005 05:06 PM
One DHCP server serving 2 subnets scng Linux - Networking 3 07-12-2005 09:57 AM
how can i create subnets on dhcp server castify Linux - Networking 0 07-24-2003 03:13 AM


All times are GMT -5. The time now is 03:10 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration