LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Answering to a single DHCP request from command line (for temp device configuration)? (https://www.linuxquestions.org/questions/linux-networking-3/answering-to-a-single-dhcp-request-from-command-line-for-temp-device-configuration-840687/)

jo2 10-27-2010 02:19 AM

Answering to a single DHCP request from command line (for temp device configuration)?
 
I'm often configuring different devices. For that I have two Ethernet interfaces in my Ubuntu pc. Eth0 interface uses dhcp to receive IP for public network, and eth1 interface is configured manually to match network settings of the device to be configured.

However some of devices which I have to configure are requesting address by dhcp. Is there way to not run dhcp server for them, but just issue single IP temporarily for the configuration process. And of course it should not mess up my normal routing table.

Ideally I'm looking something like
./give_ip 10.1.1.17 -i eth1

Probably some dhcp servers programs could do this, but mayby I have not found the correct search terms yet.

All the help is appreciated. Thanks, Jo2

business_kid 10-27-2010 02:40 AM

The dhcp interchange is quite complicated.
If you use a dhcp server you can assign IPs to the boxes that log in. Way to go. The dhcp process is not trivial.

jo2 10-27-2010 02:55 AM

Quote:

Originally Posted by business_kid (Post 4140603)
The dhcp interchange is quite complicated.
If you use a dhcp server you can assign IPs to the boxes that log in. Way to go. The dhcp process is not trivial.

Thank you for suggestion. I have used dhcp server for that, but I do not want to run dhcp server by default as it can interfere with other things. One thing is that the interface gets it's IP range changed quite often.

Solution could be any dhcp server software, which can be instructed to issue single IP address to selected interface. I assume that one of the servers must have sufficient command line options and I just have not found it yet.

prayag_pjs 10-27-2010 03:23 AM

HI,

If you have DHCP Linux server then try to bind the MAC address of a particular system to a fixed IP like given below:

Quote:

host ns2 {
next-server ns2.your-domain.com;
hardware ethernet 00:02:c3:d0:e5:83;
fixed-address 192.168.10.100;
}

jschiwal 10-27-2010 03:55 AM

Even a cable/dns router allows you to assign fixed IP addresses to certain hosts based on their MAC address. I do this at home, using a Linksys wireless router. This enables me to maintain a constant /etc/hosts file.

You can configure your first interface to use DHCP and the second manually. The Ubuntu host won't request an address from DHCP if you don't configure it to.

Also, most routers have a range where they assign addresses. By default a Linksys router will start at at .100 for the last octet. Assign your manual IPs from .2 to .99 and you won't have any conflicts.

jo2 10-27-2010 06:47 AM

Quote:

Originally Posted by prayag_pjs (Post 4140651)
HI,

If you have DHCP Linux server then try to bind the MAC address of a particular system to a fixed IP like given below:


This requires me to edit configuration file for each client device and restart the service. Point is that I have a large number of devices that I have randomly play around. Devices are connected one by one directly to eth1, so from my point of view simply approach would be to give selected ip to next client requesting one.

Entering data to configuration file is something that I can do, but I was wishing that I control everything directly from a command line tool. :)

Thank you for your input!

prayag_pjs 10-27-2010 06:54 AM

Hi,

Generally DHCP server is only one in single network.So you have to edit only server.I don't get the exact problem you are facing.


All times are GMT -5. The time now is 08:53 PM.