0

i want to get new public IP addresses from DHCP and add it to my etc0 device.

how can i get IPs and append them? and also is there any limit on it?

i talked to network manager on my datacenter and he said there is no issue for getting new IPs.

** please note that i want to append new ip addresses to my device, i don't want to change it

Pezhvak
  • 117
  • 5

2 Answers2

5

Your interface already has an IP address and you want another via DHCP?

In that case, this will most likely not work as the DHCP server will know it already gave out IP address X to the device with MAC address Y and just hand out the same one again.

Sven
  • 98,649
  • 14
  • 180
  • 226
  • so how can i do that, should i manually set ip address? is there any other way? – Pezhvak Oct 31 '18 at 19:55
  • Manually or with some sort of config management tool like Ansible or Puppet ... – Sven Oct 31 '18 at 19:56
  • 1
    A DHCP client can send a string to use as identification rather than the MAC address. So it is possible to get two IP addresses through DHCP for the same interface that way. But dynamic configuration of the IP addresses probably isn't the best choice in this case even if you can make DHCP do it. – kasperd Oct 31 '18 at 20:49
4

In addition to what Sven said: although the DHCP server won't be able to assign you more than one ip-address and the extra ip-addresses won't be configured automatically on your server ; does not mean that once assigned you can't configure them manually.

You need to configure them manually actually.

As usual there are many ways to do so (persistenly) depending on preference and ability.
Our friends from IBM need a complete book for that: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/

But that can be as simple as:

sudo ip addr add 192.168.5.213 dev etc0
HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • as far as i know this method works, but it only works until reboot, any idea about that? also how can i add IP blocks? – Pezhvak Oct 31 '18 at 20:10
  • The trivial old-school way of adding scripts to rc.local still works even in the systemd world `chmod +x /etc/rc.d/rc.local` and add the commands you need to execute at system boot - but much more proper ways with netwrok manager and/of ifcfg device scripts exist as well as adding an alias section to dhclient.conf – HBruijn Oct 31 '18 at 20:16