Static AND dhcp on same NIC? - Networking

This is a discussion on Static AND dhcp on same NIC? - Networking ; Hi - I've got a machine that for various reason I cannot have a static IP address for on the LAN. I also need to ssh in and admin the box (and I can't keep a monitor attached to it). ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Static AND dhcp on same NIC?

  1. Static AND dhcp on same NIC?

    Hi - I've got a machine that for various reason I cannot have a static
    IP address for on the LAN. I also need to ssh in and admin the box
    (and I can't keep a monitor attached to it).

    So my first thought was to try and give the box a dhcp lease on the
    primary interface (eth0) and a static address on a different network
    on eth0:0. I would then configure my client machine to also have an
    alias on that network. That way, the box would be able to get to the
    net via the dhcp lease, and I would be able to ssh in via its static
    IP.

    Like this:

    # The primary network interface (dynamic)
    allow-hotplug eth0
    iface eth0 inet dhcp

    # The secondary interface (static)
    auto eth0:0 inet static
    address 192.168.1.1
    netmask 255.255.255.0
    network 192.168.0.0
    gateway 192.168.1.1

    (note that the dhcp leases are in the range 172.20.*.*)

    However, when I try that, I get:

    /etc/init.d/networking restart
    Reconfiguring network interfaces.../etc/network/interfaces:16:
    misplaced option
    ifdown: couldn't read interfaces file "/etc/network/interfaces"
    /etc/network/interfaces:16: misplaced option
    ifup: couldn't read interfaces file "/etc/network/interfaces"

    Does anyone know if it's even possible to do this? If so, how?

    Thanks.


  2. Re: Static AND dhcp on same NIC?

    Jonathan wrote:
    > Hi - I've got a machine that for various reason I cannot have a static
    > IP address for on the LAN. I also need to ssh in and admin the box
    > (and I can't keep a monitor attached to it).
    >
    > So my first thought was to try and give the box a dhcp lease on the
    > primary interface (eth0) and a static address on a different network
    > on eth0:0. I would then configure my client machine to also have an
    > alias on that network. That way, the box would be able to get to the
    > net via the dhcp lease, and I would be able to ssh in via its static
    > IP.
    >
    > Like this:
    >
    > # The primary network interface (dynamic)
    > allow-hotplug eth0
    > iface eth0 inet dhcp
    >
    > # The secondary interface (static)
    > auto eth0:0 inet static
    > address 192.168.1.1
    > netmask 255.255.255.0
    > network 192.168.0.0
    > gateway 192.168.1.1
    >
    > (note that the dhcp leases are in the range 172.20.*.*)
    >
    > However, when I try that, I get:
    >
    > /etc/init.d/networking restart
    > Reconfiguring network interfaces.../etc/network/interfaces:16:
    > misplaced option
    > ifdown: couldn't read interfaces file "/etc/network/interfaces"
    > /etc/network/interfaces:16: misplaced option
    > ifup: couldn't read interfaces file "/etc/network/interfaces"
    >
    > Does anyone know if it's even possible to do this? If so, how?
    >
    > Thanks.
    >


    Depending on the dhcp server you have, you should be able to give a
    fixed ip from the dhcp server. That way your box gets its IP address
    (and routing information, dns, etc.) from the DHCP server as usual, but
    you are guaranteed to get the same IP address each time. Additionally,
    if your DHCP server plays well with a DNS server (I use dnsmasq - it
    handles both DHCP and DNS serving), then you can ssh into your box by
    name rather than the specified IP address.

  3. Re: Static AND dhcp on same NIC?

    Jonathan wrote:
    > Hi - I've got a machine that for various reason I cannot have a static
    > IP address for on the LAN. I also need to ssh in and admin the box
    > (and I can't keep a monitor attached to it).
    >
    > So my first thought was to try and give the box a dhcp lease on the
    > primary interface (eth0) and a static address on a different network
    > on eth0:0. I would then configure my client machine to also have an
    > alias on that network. That way, the box would be able to get to the
    > net via the dhcp lease, and I would be able to ssh in via its static
    > IP.
    >
    > Like this:
    >
    > # The primary network interface (dynamic)
    > allow-hotplug eth0
    > iface eth0 inet dhcp
    >
    > # The secondary interface (static)
    > auto eth0:0 inet static
    > address 192.168.1.1
    > netmask 255.255.255.0
    > network 192.168.0.0
    > gateway 192.168.1.1
    >
    > (note that the dhcp leases are in the range 172.20.*.*)
    >
    > However, when I try that, I get:
    >
    > /etc/init.d/networking restart
    > Reconfiguring network interfaces.../etc/network/interfaces:16:
    > misplaced option
    > ifdown: couldn't read interfaces file "/etc/network/interfaces"
    > /etc/network/interfaces:16: misplaced option
    > ifup: couldn't read interfaces file "/etc/network/interfaces"
    >
    > Does anyone know if it's even possible to do this? If so, how?
    >
    > Thanks.
    >


    You could make a reservation for your workstation's MAC address at the
    DHCP server. It would still be getting its address and all of the
    options via DHCP, but you would be guaranteed the same IP address every
    time.

    I don't think you can have a static and a dynamic configuration on the
    same physical interface (though I'm sure someone may prove me wrong).

    Kurt


  4. Re: Static AND dhcp on same NIC?

    Jonathan wrote:
    > Hi - I've got a machine that for various reason I cannot have a static
    > IP address for on the LAN. I also need to ssh in and admin the box
    > (and I can't keep a monitor attached to it).
    >
    > So my first thought was to try and give the box a dhcp lease on the
    > primary interface (eth0) and a static address on a different network
    > on eth0:0. I would then configure my client machine to also have an
    > alias on that network. That way, the box would be able to get to the
    > net via the dhcp lease, and I would be able to ssh in via its static
    > IP.
    >
    > Like this:
    >
    > # The primary network interface (dynamic)
    > allow-hotplug eth0
    > iface eth0 inet dhcp
    >
    > # The secondary interface (static)
    > auto eth0:0 inet static
    > address 192.168.1.1
    > netmask 255.255.255.0
    > network 192.168.0.0


    network 192.168.1.0

    > gateway 192.168.1.1
    >
    > (note that the dhcp leases are in the range 172.20.*.*)
    >
    > However, when I try that, I get:
    >
    > /etc/init.d/networking restart
    > Reconfiguring network interfaces.../etc/network/interfaces:16:
    > misplaced option
    > ifdown: couldn't read interfaces file "/etc/network/interfaces"
    > /etc/network/interfaces:16: misplaced option
    > ifup: couldn't read interfaces file "/etc/network/interfaces"
    >
    > Does anyone know if it's even possible to do this? If so, how?
    >
    > Thanks.





  5. Re: Static AND dhcp on same NIC?


    > You could make a reservation for your workstation's MAC address at the
    > DHCP server. It would still be getting its address and all of the
    > options via DHCP, but you would be guaranteed the same IP address every
    > time.
    >
    > I don't think you can have a static and a dynamic configuration on the
    > same physical interface (though I'm sure someone may prove me wrong).
    >


    Sorry, I should have added that I don't have any access or control
    over the router/dhcp server,so I can't have a fixed IP assigned to the
    MAC address.

    I think you may be right on the second point. No matter what I try
    it's not having it, so perhaps I need to do it on a separate physical
    interface.


  6. Re: Static AND dhcp on same NIC?

    kurt wrote:
    > Jonathan wrote:
    >> Hi - I've got a machine that for various reason I cannot have a static
    >> IP address for on the LAN. I also need to ssh in and admin the box
    >> (and I can't keep a monitor attached to it).
    >>
    >> So my first thought was to try and give the box a dhcp lease on the
    >> primary interface (eth0) and a static address on a different network
    >> on eth0:0. I would then configure my client machine to also have an
    >> alias on that network. That way, the box would be able to get to the
    >> net via the dhcp lease, and I would be able to ssh in via its static
    >> IP.
    >>
    >> Like this:
    >>
    >> # The primary network interface (dynamic)
    >> allow-hotplug eth0
    >> iface eth0 inet dhcp
    >>
    >> # The secondary interface (static)
    >> auto eth0:0 inet static
    >> address 192.168.1.1
    >> netmask 255.255.255.0
    >> network 192.168.0.0
    >> gateway 192.168.1.1
    >>
    >> (note that the dhcp leases are in the range 172.20.*.*)
    >>
    >> However, when I try that, I get:
    >>
    >> /etc/init.d/networking restart
    >> Reconfiguring network interfaces.../etc/network/interfaces:16:
    >> misplaced option
    >> ifdown: couldn't read interfaces file "/etc/network/interfaces"
    >> /etc/network/interfaces:16: misplaced option
    >> ifup: couldn't read interfaces file "/etc/network/interfaces"
    >>
    >> Does anyone know if it's even possible to do this? If so, how?
    >>
    >> Thanks.
    >>

    >
    > You could make a reservation for your workstation's MAC address at the
    > DHCP server. It would still be getting its address and all of the
    > options via DHCP, but you would be guaranteed the same IP address every
    > time.
    >
    > I don't think you can have a static and a dynamic configuration on the
    > same physical interface (though I'm sure someone may prove me wrong).
    >
    > Kurt
    >

    Of course you can. You just set up dhclient with an alias.

    /etc/dhclient.conf:

    interface "eth0" {
    script "/etc/dhclient-script";
    send host-name "peregrine";
    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, host-name,
    interface-mtu;
    require subnet-mask, domain-name-servers;
    default domain-name "verizon.net";
    }

    alias { interface "eth0";
    fixed-address 172.23.77.6;
    option subnet-mask 255.255.255.0;
    }

    This gets a dynamic address from the DSL modem/router and also creates
    an alias interface for the internal lan, with a fixed address.

    Now how you accomplish this with certain distributions fancy network
    scripts I have no idea, but it _can_ be done.

    Jerry

  7. Re: Static AND dhcp on same NIC?

    Awesome! Thanks for that, Jerry.

    Kurt


    Jerry Peters wrote:
    > kurt wrote:
    >> Jonathan wrote:
    >>> Hi - I've got a machine that for various reason I cannot have a static
    >>> IP address for on the LAN. I also need to ssh in and admin the box
    >>> (and I can't keep a monitor attached to it).
    >>>
    >>> So my first thought was to try and give the box a dhcp lease on the
    >>> primary interface (eth0) and a static address on a different network
    >>> on eth0:0. I would then configure my client machine to also have an
    >>> alias on that network. That way, the box would be able to get to the
    >>> net via the dhcp lease, and I would be able to ssh in via its static
    >>> IP.
    >>>
    >>> Like this:
    >>>
    >>> # The primary network interface (dynamic)
    >>> allow-hotplug eth0
    >>> iface eth0 inet dhcp
    >>>
    >>> # The secondary interface (static)
    >>> auto eth0:0 inet static
    >>> address 192.168.1.1
    >>> netmask 255.255.255.0
    >>> network 192.168.0.0
    >>> gateway 192.168.1.1
    >>>
    >>> (note that the dhcp leases are in the range 172.20.*.*)
    >>>
    >>> However, when I try that, I get:
    >>>
    >>> /etc/init.d/networking restart
    >>> Reconfiguring network interfaces.../etc/network/interfaces:16:
    >>> misplaced option
    >>> ifdown: couldn't read interfaces file "/etc/network/interfaces"
    >>> /etc/network/interfaces:16: misplaced option
    >>> ifup: couldn't read interfaces file "/etc/network/interfaces"
    >>>
    >>> Does anyone know if it's even possible to do this? If so, how?
    >>>
    >>> Thanks.
    >>>

    >> You could make a reservation for your workstation's MAC address at the
    >> DHCP server. It would still be getting its address and all of the
    >> options via DHCP, but you would be guaranteed the same IP address every
    >> time.
    >>
    >> I don't think you can have a static and a dynamic configuration on the
    >> same physical interface (though I'm sure someone may prove me wrong).
    >>
    >> Kurt
    >>

    > Of course you can. You just set up dhclient with an alias.
    >
    > /etc/dhclient.conf:
    >
    > interface "eth0" {
    > script "/etc/dhclient-script";
    > send host-name "peregrine";
    > request subnet-mask, broadcast-address, time-offset, routers,
    > domain-name, domain-name-servers, host-name,
    > interface-mtu;
    > require subnet-mask, domain-name-servers;
    > default domain-name "verizon.net";
    > }
    >
    > alias { interface "eth0";
    > fixed-address 172.23.77.6;
    > option subnet-mask 255.255.255.0;
    > }
    >
    > This gets a dynamic address from the DSL modem/router and also creates
    > an alias interface for the internal lan, with a fixed address.
    >
    > Now how you accomplish this with certain distributions fancy network
    > scripts I have no idea, but it _can_ be done.
    >
    > Jerry


  8. Re: Static AND dhcp on same NIC?

    In article ,
    kurtl@olypen.com (kurt) writes:

    > I don't think you can have a static and a dynamic configuration on the
    > same physical interface (though I'm sure someone may prove me wrong).


    Sure you can. I tell my DHCP server not to assign any addresses
    below 192.168.0.32, and put all my static addresses in that range.

    --
    /~\ cgibbs@kltpzyxm.invalid (Charlie Gibbs)
    \ / I'm really at ac.dekanfrus if you read it the right way.
    X Top-posted messages will probably be ignored. See RFC1855.
    / \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!


+ Reply to Thread