LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-09-2005, 11:32 PM   #1
srikanthrao_d
Member
 
Registered: Oct 2005
Posts: 32

Rep: Reputation: 15
DHCP Sever Different VLAN


Hi

I have four VLANs on my network, i want maintain single DHCP server, how can i do that thing on single sever? is i need add vitual interface on the server? I need add too many LAN card on the server ? what are steps i need to do ?

Thanks,
Srikanth
 
Old 11-10-2005, 05:36 PM   #2
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

if your IP addressing is correctly set (a subnet per vlan), then it's very easy.

in dhcpd.conf, you'll have a declaration of every subnet, with the range of IPs you want to "offer" in it.
i'm sorry i don't have a sample config file... i moved from france to ireland and my former flatmates inherited of the dhcp server

from man dhcpd.conf it should look like this:
Code:
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.1 192.168.1.200;
    option routers 192.168.1.254;
  }
subnet 192.168.2.0 netmask 255.255.255.0 {
    range 192.168.2.1 192.168.2.200;
    option routers 192.168.2.254;
  }
of course, you can add all the options you want, either global or in the subnet declarations.
you need to have a subnet declaration for every IP subnet declared on your machine.

then you install support for vlan on your machine (vconfig), and the esaiest way should be to set up a 802.1q trunk port on your net interface:

Code:
vconfig add eth0.1 1 # associate eth0.1 (subinterface of eth0) to vlan 1
vconfig add eth0.2 2 # associate eth0.2 (subinterface of eth0) to vlan 2
ifconfig eth0 0.0.0.0 up # eth0 is up, but has no IP, cause we'll only use the vlans
ifconfig eth0.1 192.168.1.254 up # give an ip to this interface, it should match the dhcpd.conf subnets
ifconfig eth0.2 192.168.2.254 up # give an ip to this interface, it should match the dhcpd.conf subnets
restart dhcpd and, it should work (provided the switch you're plugged in is configured to allow you the access these vlans, ie you're on a trunk/802.1Q port)

when a client makes a dhcp request in vlan 1, eth0.1 will get it, and dhcpd.conf will know from which subnet it should give an IP according to the IP address configured on eth0.1.

Note 1: my exemple might be bad as some switches have special use for vlan 1...

Note 2: cool, but my vlans are routed, so my dhcp server cannot use all these IP addresses, it must be in a different vlan and subnet...
no prob, see dhcrelay which allows you to use the same config without using vlans on the dcp server... but the router that interconnects the vlan must be a dhcrelay (Linux box and cisco are no prob, i believe major vendors are ok as well)
 
Old 11-14-2005, 11:48 AM   #3
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
You can connect your DHCP server to each vlan if you want, however if you are allready routing between the VLANs with a router or L3 switch, the all you need to do is enable your router or L3 switch to forward bootp requests to the DHCP server. Cisco call this "bootp helper", I think Nortel call it a "DHCP Relay", you'll normally find a similar function. This forwards DHCP broadcasts, which are basically extended bootp requests, to the unicast address of your DHCP server. It also source stamps the request so that the DHCP server knows which pool to assign from and where to return the response.
 
Old 11-17-2007, 11:11 PM   #4
hafeezisbad
Member
 
Registered: Nov 2007
Posts: 32

Rep: Reputation: 0
hi i am memeber of linux,org

i am a linux user but i am facing a problem to setup a dhcp server on fedora for a vlan setup with layer 3 switch

my vlan 10 shuld be 192.168.10.x series ip
vlan 20 shuld be 192.168.20.x

vlan30 shuld be 192.168.30.x

its so easy with windows creating scopes but in linux , the service fails when i enter subnet

ddns-update-style interim;
dynamic-bootp-lease-length 86400;
max-lease-time 604800;
default-lease-time 604800;

subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
option nis-domain "xyz.net";
option domain-name "xyz.net";
option domain-name-servers 192.168.10.2;
option time-offset -18000;
authoritative;
option ntp-servers 192.168.10.2;
option netbios-name-servers 192.168.10.2;
option netbios-node-type 2;
range 192.168.10.50 192.168.10.220;
}

it works and when i try to create other subnets or scopes below ,, it fails to restart , i checked /var/log/messages ,, its says dhcp exited multiple subnet not supported i am using fedora 7

ddns-update-style interim;
dynamic-bootp-lease-length 86400;
max-lease-time 604800;
default-lease-time 604800;

subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
option nis-domain "xyz.net";
option domain-name "xyz.net";
option domain-name-servers 192.168.10.2;
option time-offset -18000;
authoritative;
option ntp-servers 192.168.10.2;
option netbios-name-servers 192.168.10.2;
option netbios-node-type 2;
range 192.168.10.50 192.168.10.220;
}
subnet 192.168.20.0 netmask 255.255.255.0 {
option routers 192.168.20.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
option nis-domain "xyz.net";
option domain-name "xyz.net";
option domain-name-servers 192.168.10.2;
option time-offset -18000;
authoritative;
option ntp-servers 192.168.10.2;
option netbios-name-servers 192.168.10.2;
option netbios-node-type 2;
range 192.168.20.50 192.168.20.220;
}

plz help me with this problem , is linux not a good opeating system for dhcp server , when compared to windows2003

i am fan of linux but this is dissapointing me now ,

thanks in advance , try to suggest some solution
 
Old 04-28-2011, 10:43 AM   #5
rporro
LQ Newbie
 
Registered: Apr 2011
Distribution: Debian
Posts: 18

Rep: Reputation: 6
PROBLEMS DHCP debian lenny huawey L3

Hi every one, I have a problem in my network, it's that I have created a dhcp in debian lenny servicing 4 vlan my config is the one as fallow:

shared-network MI_EMPRESA{
next-server 172.16.30.10;
filename "VLDRMI13.BIN";
option domain-name-servers 172.16.30.22;
option domain-name "cubatel.cu";
subnet 172.16.30.0 netmask 255.255.255.0{
option routers 172.16.30.253;
}
subnet 172.16.31.0 netmask 255.255.255.0{
range 172.16.31.1 172.16.31.100;
option routers 172.16.31.253;
}
subnet 172.16.32.0 netmask 255.255.255.0{
range 172.16.32.1 172.16.32.100;
option routers 172.16.32.253;
}
subnet 172.16.33.0 netmask 255.255.255.0{
range 172.16.33.1 172.16.33.100;
option routers 172.16.33.253;
}
}

and the problem is that computers on the network 33.0 (and only this one)recieve ip's from others scopes and of course they don't have access to my network services.

Let my tell you that I have a switch huawey l3 and dhcp relay is confured and tested because previusly I had a WIN DHCP the one that is working now.

PLEASE I accept any suggestions and thank's every body

P.D. Sorry about my English wish is kind of rusty

Last edited by rporro; 04-28-2011 at 10:45 AM. Reason: private info released, sorry
 
Old 04-29-2011, 06:13 AM   #6
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
Try using wireshark on the server, or tshark or tcpdump. Get a trace of the DHCP request. If the source of the request is set as 172.16.33.0 then the problem is likely internal to the server. If the source is still set as 0.0.0.0 then the problem is the L3 switch not source stamping the DHCP request.

The server relies on the source stamp to know which scope to assign from or typically it will assign from the first scope.
 
1 members found this post helpful.
Old 04-29-2011, 10:31 AM   #7
rporro
LQ Newbie
 
Registered: Apr 2011
Distribution: Debian
Posts: 18

Rep: Reputation: 6
thanks baldy I havent thought that and when I tried I realized that My switch L3 ask with the Vlan he likes, thank's again
 
Old 05-03-2011, 05:36 AM   #8
mark.
LQ Newbie
 
Registered: Apr 2009
Distribution: Centos,Fed,Ubuntu,Linpus
Posts: 3

Rep: Reputation: 1
Hi,

I have been working on a project like this over the last few days and found some of the help here useful.
But i also wanted to add something else for rporro:

You have used the shared network statement at the top of your config.
As i gather this pools all of your available IP's together and the server will issue IP's as it gets them from the pool.
I was finding a machine on any vlan that was requesting an IP was being given one from the last vlan IP pool as it hadn't been used up.

As soon as i removed the shared network statement the issue was resolved and each vlan machine got an IP from the correct pool.

Hope this helps someone now or in the future.
Mark
 
1 members found this post helpful.
Old 05-04-2011, 01:53 PM   #9
rporro
LQ Newbie
 
Registered: Apr 2011
Distribution: Debian
Posts: 18

Rep: Reputation: 6
Thanks mark for your opinion, I've tried that to and it did't work, now I'm trying to configure the VLANS variant on the begining of the page Them I will ask if there is anything that didn't work
 
Old 12-01-2018, 08:03 PM   #10
hafeezisbad
Member
 
Registered: Nov 2007
Posts: 32

Rep: Reputation: 0
Hello guys

i do remeber my first dhcp server i ever set up was a linux mahine 12 years ago
every time people say windows dhcp server ,, for vlans and i smiled
any way keep in mind , linux kernal which have support for 802.q will able to serve dhcp service also
example here :

yum install dhcpd ( for fedora or rhel /cent)
dnf install dhcpd

apt-get install dhcpd ( ubuntu or db)
step 2 . create virtual interfaces , you do no need more phy interfaces
in example to make 3 vlan ,, 10.10.10.x , 10.10.20.x , 10.10.30.x

nmcli con modify type vlan ifname vlan10 dev ens33 id 10 ip4 10.10.10.1/24 gw4 10.10.10.254
nmcli con add type vlan ifname vlan10 dev ens33 id 10 ip4 10.10.10.1/24 gw4 10.10.10.254
nmcli con add type vlan ifname vlan20 dev ens33 id 20 ip4 10.10.20.1/24 gw4 10.10.20.254
nmcli con add type vlan ifname vlan30 dev ens33 id 30 ip4 10.10.30.1/24 gw4 10.10.30.254
this for fedora or rhel latest version
if for ubuntu
command is
vconfig add ens33 10
vconfig add ens33 20

then
Configure the network settings for the VLAN interfaces:
# ip addr add 10.10.10.1/24 dev ens33.10
Bring up the VLAN interface:
# ip link set eth33.10 up
do for all interfaces in ubuntu

then check ip address ,,, you can see virutal interfaces pinging

then

# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

subnet 10.10.0.0 netmask 255.255.0.0 {
}

# This is a very basic subnet declaration.

subnet 10.10.10.0 netmask 255.255.255.0 {
range 10.10.10.1 10.10.10.20;
option routers 10.10.10.1;
}
subnet 10.10.20.0 netmask 255.255.255.0 {
range 10.10.20.1 10.10.20.20;
option routers 10.10.20.1;
}
subnet 10.10.30.0 netmask 255.255.255.0 {
range 10.10.30.1 10.10.30.20;
option routers 10.10.30.1;
}

save start the service and your good to go ,,, connect to trunk port of switch and check it ,,

any doubts ,, do let me know
my email :hafeezisbad@yahoo.com
tech consultant





A working configuration example from hafeezisbad@gmail.com

Server ip : 172.27.0.10
Swtich ip / gateway ip of server : 172.27.0.100
Option domain –name servers : 172.27.0.6

Please note default vlan 172.27.0.x in this case

Switch and server need to be in default lan for communication / or else we need to trunk in case other vlan connected , we need to configure vconfig on server to communicate


For biggner I would recommend to go for the default vlan connectivity


Example :

ddns-update-style interim;
ignore client-updates;
default-lease-time 43200;
max-lease-time 43200;
authoritative;


#-----subnet mask-- broadcast-- gateway-#

option subnet-mask 255.255.255.0;
#option broadcast-address 192.168.1.1;
option routers 172.27.0.100;
option domain-name-servers 172.27.0.6;


# ----------- Server Scope and vlan1 with switches and server--------------#
subnet 172.27.0.0 netmask 255.255.255.0 {
#range 172.27.0.0 172.27.0.50;
option routers 172.27.0.1;
#option subnet-mask 255.255.255.0;
option broadcast-address 172.27.0.255;
#option domain-name-servers 172.27.0.5;
}


# ----------- clients1 Scope-vlan2-------------#
subnet 172.27.1.0 netmask 255.255.255.0 {
range 172.27.1.3 172.27.1.200;
option routers 172.27.1.1;
option subnet-mask 255.255.255.0;
option broadcast-address 172.27.1.255;
#option domain-name-servers 192.168.1.1 #
}


Save the file

Chkconfig –list dhcpd on
{ For enabling the service on all run levels }
Service dhcpd start
In case , dhcp server faild to start , check with log messages

/var/log/messages

Check for the ip helper address in layer 3 swtich , which act as dhcp-relay
Which has to be configured as 172.27.0.10


Troubleshooting Dhcp server start up error :

1) Run the Dhcp service in debug mode
2) Check the ip configuration
3) Check for syntax errors in dhcpd.conf file
4) Check for the right location of the dhcpd file
5) Ping test between the switch and server
6) Possible conflict of other dhcp server may be the issue

dhcpd in the foreground in debug mode with /usr/sbin/dhcpd -d –f

Hopefully, a DHCP server like the one we’ll be configuring will respond. Running tcpdump shows a dhcp request looks like:
17:26:02.003956 00:00:00:00:00:00 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0×0800), length 342: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request, length 300
You should notice DHCP running in the process (ps) list. Any problems, check syslog

Congratulations you have finally configured In easy steps
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vlan switching fr_laz Linux - Networking 1 07-08-2005 10:49 PM
Vlan not sepparate collen Linux - Networking 0 06-08-2004 07:22 AM
Vlan Markvw Linux - Networking 1 09-29-2003 08:33 AM
Mandrake DHCP sever setup woas... AudioMechanic Linux - Networking 1 06-15-2003 07:54 PM
manual setup for dhcp sever using redhat 7.0 for newbie Shaun Linux - Networking 1 06-07-2002 11:35 AM

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

All times are GMT -5. The time now is 06:18 AM.

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