2
1
If I do dhclient eth1
, it obtains the information (IP address, router, DNS, etc.) and applies it to routing table, /etc/resolv.conf
and so on.
How to only get and print the information from DHCP server without touching the network configuration?
Currently I use dhcdrop -t
, but it is not the right tool for the job.
Should the information to be obtained be related to the interface eth1 as in your sample? – Serge – 2012-10-02T19:16:48.930
Yes. – Vi. – 2012-10-02T19:50:48.683
One more question. The already cached information is not enough? – Serge – 2012-10-02T19:57:40.160
Already cached information on freshly set up or not DHCP-maanged interface? Actually the one use case is to set IP and some routes based on DHCP reply, but not DNS. – Vi. – 2012-10-02T20:04:09.760
You did not mention in the question that this is a freshly setup machine as well as that the interface is not dhcp managed. – Serge – 2012-10-02T20:06:15.860
Going to be requested on connection (hacky scheme). Proper scheme whould be DHCP client that keeps running and dumps replies from DHCP server where I can interpret and execute (or not execute) orders from it in my script. It can also be useful when you want to connect to multiple DHCP-managed networks. One of DHCP servers tell you "10.4.5.6 is defalt router", but you interpret it as "10.4.5.6 is router for 10.4.0.0/16" and so on. – Vi. – 2012-10-02T20:14:26.087
@Serge, "You did not mention in the question" -> The solution should just send and receive the appropriate packets and not mess with routes/DNS/addresses/whatever. Almost like "query DHCP server from non-root" (if raw network were allowed for users). – Vi. – 2012-10-02T20:17:27.307
Yes, I got you. – Serge – 2012-10-02T20:19:55.093