Re: DHCP and static IP configuration hangs when no DHCP

Hi David,

On 6/12/19 8:17 PM, David Bourgeois wrote:
The only hack I found is to create a static IP only, then in add a up-post script that manually launches dhclient on the interface. That does what I need but it's somehow cumbersome.

On Wed, Jun 12, 2019 at 8:15 PM David Bourgeois <david jaguarondi com <mailto:david jaguarondi com>> wrote:

    Hi Francesco,

    Thank you for your answer. I can indeed do that to keep DHCP trying
    forever or nearly, that's a good idea. But my problem is that the
    static IP is not created at all until there's an answer from a DHCP
    server. I was expecting that the static IP would be created then the
    dynamic IP would appear whenever the DHCP answers. But they both
    appear only when the DHCP answers. i'm unable to create a static IP
    first, then start DHCP. Any idea?

This is weird, as I just gave it a try and works by assigning the static ip first, then keeping trying the dhcp. If the dhcp timeouts, the connection fails and is teared down, clearing also the static ip that was configured. This is why the trick worked for me.
Which NM version do you have?
Can you confirm that when the connection is in the "connecting" state (check with 'nmcli connection') the ip address is not assigned (check for the ip with 'ip add')?




    On Wed, Jun 12, 2019 at 10:26 AM Francesco Giudici
    <fgiudici redhat com <mailto:fgiudici redhat com>> wrote:

        Hi David,

        On 6/11/19 12:24 AM, David Bourgeois wrote:
         > Hi,
         > I can't find the proper configuration to have an always
        enabled static
         > IP address and an optional DHCP address when connected to a
        network that
         > has a DHCP server. My use case is a portable device that
        connects to
         > local embedded devices using a private local LAN so the
        static IP should
         > always be there. When we need to connect on the internet, I
        would like
         > to plug a DHCP enabled connection to the switch and receive a
        second IP
         > automatically from DHCP for this.
         > I can setup both DHCP and static using this configuration:
         > [ipv4]
         > address1= <>
         > method=auto
         > The problem is that the whole connection profile will fail if
        no DHCP
         > server is found, the static IP will never be set. As soon as
        I plug the
         > DHCP network, both IP will appear. But I would need the
        static IP to be
         > available from the beginning. I have the same problem if I
        try the
         > ifupdown configuration through /etc/network/interfaces. I had
        gentoo in
         > the past and could achieve this using their RC system, DHCP
        would be
         > assigned to eth0:0 and a static IP to eth0:1. I just can't
        find a way to
         > do this with Network Manager.
         > Any idea if that's possible with the profile configuration,
        or if I need
         > to use 2 configurations or play with some scripts?

        I think you can achieve your desired configuration by setting
        the dhcp
        timeout value to something really big.
        As easy as:

        $ nmcli connection modify $YOUR_CONNECTION_NAME
        ipv4.dhcp-timeout infinity

        This way, the connection will keep trying getting an ip from
        time to
        time, and will never be teared down.


         > Thank you,
         > David
         > _______________________________________________
         > networkmanager-list mailing list
         > networkmanager-list gnome org
        <mailto:networkmanager-list gnome org>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]