Networking Forums

Networking Forums > Computer Networking > Linux Networking > Static AND dhcp on same NIC?

Reply
Thread Tools Display Modes

Static AND dhcp on same NIC?

 
 
Jonathan
Guest
Posts: n/a

 
      06-11-2008, 12:47 PM
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.

 
Reply With Quote
 
 
 
 
David Brown
Guest
Posts: n/a

 
      06-11-2008, 08:10 PM
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.
 
Reply With Quote
 
kurt
Guest
Posts: n/a

 
      06-12-2008, 05:07 AM
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

 
Reply With Quote
 
trselmer@start.no
Guest
Posts: n/a

 
      06-12-2008, 10:09 AM
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.




 
Reply With Quote
 
Jonathan
Guest
Posts: n/a

 
      06-12-2008, 10:26 AM

> 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.

 
Reply With Quote
 
Jerry Peters
Guest
Posts: n/a

 
      06-12-2008, 09:13 PM
kurt <(E-Mail Removed)> 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
 
Reply With Quote
 
kurt
Guest
Posts: n/a

 
      06-13-2008, 04:07 AM
Awesome! Thanks for that, Jerry.

Kurt


Jerry Peters wrote:
> kurt <(E-Mail Removed)> 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

 
Reply With Quote
 
Charlie Gibbs
Guest
Posts: n/a

 
      06-13-2008, 05:32 PM
In article <(E-Mail Removed) ernet>,
(E-Mail Removed) (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.

--
/~\ (E-Mail Removed)lid (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 With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
static ip/dhcp on mn-700 computanerd@gmail.com Broadband Hardware 9 10-19-2007 07:36 AM
DHCP and Static IPs? HotRdd Network Routers 5 06-14-2007 11:20 PM
DI-524 Static IP while in DHCP mathieu.renaud@gmail.com Wireless Internet 5 10-12-2006 11:45 PM
DHCP Error 64 - No static IP bound to this DHCP Server DHCP Firewall Windows Networking 0 02-02-2006 04:04 PM
DHCP to static IP - is this OK? Bob O'Connor Linux Networking 3 07-05-2003 08:17 PM



1 2 3 4 5 6 7 8 9 10 11