0

I have currently built up 10 diskless servers using the instruction provided by Ubuntu. After booting up the servers, I would like to assign new IP to them separately. Since the servers root file is mounted from a single source via NFS, the interface file in /etc/network is the same.

My question is how would I configure the interface file, so that when different servers read the same file, they will be assigned with different IP?

Thank you very much

0

You wouldn't do it via the shared /etc/network/interfaces file.

To accomplish this, use dnsmasq's DHCP server. From man dnsmasq:

  The dnsmasq DHCP server supports static address assignments and multiple networks. It automatically sends a sensible default set of DHCP options, and can be configured to send any desired
   set of DHCP options, including vendor-encapsulated options. It includes a secure, read-only, TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP. The  PXE  support  is
   full featured, and includes a proxy mode which supplies PXE information to clients whilst DHCP address allocation is done by another server.

   The  dnsmasq  DHCPv6  server provides the same set of features as the DHCPv4 server, and in addition, it includes router advertisements and a neat feature which allows nameing for clients
   which use DHCPv4 and stateless autoconfiguration only for IPv6 configuration. There is support for doing address allocation (both DHCPv6 and RA) from subnets which are  dynamically  dele‐
   gated via DHCPv6 prefix delegation.

By careful reading of man dnsmasq, you will see how you can assign specific IP addresses to specific 48-bit MAC addresses (the HWaddr field of ifconfig output).

| improve this answer | |
  • What is the difference between interfaces file and dnsmasq? Actually the interface I want to assign IP is Infiniband interface. Do you know if dnsmasq support Infiniband? – user285108 Mar 7 '18 at 14:58
  • This is too complicated to explain. Search "dnsmasq DHCP" both on AskUbuntu, and with your favorite search engine. You configure the nodes to request an IP address via DHCP, and use dnsmasq on your server to assign IP addresses. You can make a "permanent" IP address assignment, if you want. – waltinator Mar 7 '18 at 22:50
  • The nodes send their DHCP request to the MAC ff:ff:ff:ff:ff:ff (the Ethernet broadcast to all nodes on the local network). In the request, the node specifies its own MAC address. The DHCP server replies with an IP address, Gateway IP, DNS servers, ...... – waltinator Mar 7 '18 at 22:53
0

You need DHCP server in you lan network or on router to assign ip parm to your servers.

You can do this with Ubuntu server.

To install dhcp service on server run command below

sudo apt install isc-dhcp-server

Change configuration based on your ip/mac address

sudo nano /etc/dhcp3/dhcpd.conf

EDIT 1 - added configuration for second dhcp pool on different card

Cconfiguration example

subnet 192.168.100.0 netmask 255.255.255.0 {
  interface eth0;
  option domain-name "domain.net";
  option broadcast-address 192.168.100.255;
  option routers 192.168.100.1;
  option domain-name-servers 192.168.100.1, 8.8.8.8;

  # Define the scopes for this DHCP pool

  pool {
   range 192.168.100.2 192.168.100.200;
   # static reserve = 192.168.100.201 - 192.168.100.254
  }
  host static-custid {
   hardware ethernet 00:01:02:03:04:05;
   fixed-address 192.168.100.205;
  }
  host static-custid {
   hardware ethernet 00:01:02:03:04:06;
   fixed address 192.168.100.206;
  }
}

subnet 10.0.0.0 netmask 255.255.255.0 {
    interface eth2;
    default-lease-time 6000;
    max-lease-time 7200;
    range 10.0.0.100 10.0.0.200;
    option subnet-mask 255.255.255.0;
    option routers 10.0.0.254;
    option broadcast-address 10.0.0.255;
}

Note: You dhcp pool is from 192.168.100.2 192.168.100.200, your netmask is 255.255.255.0 your router is on address 192.168.100.1. DHCP server will always assign Host with mac address 00:01:02:03:04:05 ip 192.168.100.205, with mac 00:01:02:03:04:06 ip 192.168.100.206. But if come host with mac 00:01:02:03:04:08 server will assign next free ip address from pool.

After change of config, restart dhcp server.

| improve this answer | |
  • Thanks for your reply. I have already got a DHCP server setup for assigning IP to the diskless clients first Ethernet interface as they boot up. Now I want to their second interface to be assigned with IP in another subnetwork. If I setup another DHCP server, will the two servers interrupt each other? – user285108 Mar 7 '18 at 7:58
  • Logic is the same if you setup second nic on diskless client to be configured via dhcp. You only need to add new interface/sub-interface on dhcp server to deliver dhcp offer to "second nic" network. and do configuration to that network. Look on my EDIT 1 in answer. – 2707974 Mar 7 '18 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.