LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-28-2016, 08:05 AM   #1
luofeiyu
Member
 
Registered: Aug 2015
Posts: 237

Rep: Reputation: Disabled
How to assign eth0 192.168.1.101 in dhcp status?


The config is as following In /etc/network/interfaces :
Code:
auto eth0
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
To reboot and input command ifconfig:

Code:
ifconfig
eth0      Link encap:Ethernet  HWaddr e0:3f:49:57:4b:d1  
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::e23f:49ff:fe57:4bd1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:821 errors:0 dropped:218 overruns:0 frame:0
          TX packets:725 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:167817 (163.8 KiB)  TX bytes:122295 (119.4 KiB)
The eth0 was assigned as 192.168.1.101
Now to change the way from static into dhcp in /etc/network/interfaces :
Code:
auto eth0
iface eth0 inet dhcp
To reboot and input command ifconfig:
Code:
ifconfig
eth0      Link encap:Ethernet  HWaddr e0:3f:49:57:4b:d1  
          inet6 addr: fd8d:7a2d:f1e2:0:e23f:49ff:fe57:4bd1/64 Scope:Global
          inet6 addr: fe80::e23f:49ff:fe57:4bd1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9939 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9617 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:8321348 (7.9 MiB)  TX bytes:1331252 (1.2 MiB)
How to assign eth0 192.168.1.101 in dhcp status?

Last edited by luofeiyu; 06-29-2016 at 07:15 AM.
 
Old 06-28-2016, 09:16 AM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,145

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
A few things, please use code tags it makes it much easier to read your post, second what distro are you using?, 3rd I may be mistaken but when using dhcp you get assigned an IP from a pool of address's so can't normally guarantee what your IP will be, although some dhcp servers allow a specific IP to be assined, I assumed based on the MAC address, my router allows this, if the IP hasn't already gone.
 
Old 06-28-2016, 10:47 AM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Your question doesn't make sense. With a static IP, the computer tells the rest of the network what address it's going to use. With a dynamic IP (DHCP), the DHCP server on the network tells the computer what address to use. You're asking how to configure the computer so that it can tell the DHCP server what address the DHCP server should assign to the computer, which is completely backasswards.

If you want a computer on DHCP to have a fixed IP, you need to set the rule in the DHCP server, which is probably your router. Most of them have some way of assigning a fixed IP based on MAC address.
 
Old 06-28-2016, 09:17 PM   #4
luofeiyu
Member
 
Registered: Aug 2015
Posts: 237

Original Poster
Rep: Reputation: Disabled
My os is debian8, it is my way to connect internet :

isp side:
to provide adsl pppoe with a account and name

my home side:
to set dhcp in /etc/network/interfaces
 
Old 06-28-2016, 09:42 PM   #5
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,303
Blog Entries: 28

Rep: Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135Reputation: 6135
Quote:
How to assign eth0 192.168.1.101 in dhcp status?
You can't.

Having a static ip address and using DHCP are mutually exclusive.

You might be able to tell your router to assign a specific ip address to the MAC address of your computer, but that's a different question, and the pros and cons of it are under debate. https://startpage.com/do/dsearch?que...nguage=english
 
Old 06-29-2016, 07:13 AM   #6
luofeiyu
Member
 
Registered: Aug 2015
Posts: 237

Original Poster
Rep: Reputation: Disabled
Having a static ip address and using DHCP are mutually exclusive.
May be my idea was misread.
I have telled two status to set ip in my pc.
status 1.

Code:
auto eth0
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
status 2

Code:
auto eth0
iface eth0 inet dhcp
To reset the configuration when static ip(status) was tested.
Now in /etc/network/interfaces,it is

Code:
auto eth0
iface eth0 inet dhcp
Not as the following in /etc/network/interfaces

Code:
auto eth0
iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
I think maybe it can be done.
No matter what kind of status,there are tow kinds of ip for my pc's eth0: `public` and `private` ip.
The public ip which it is set by my ISP,my isp is a dhcp server ,my pc is a dhcp client.
It is a fact for both status 1 and status 2.
In status 1 ,my private eth0's ip was set to 192.168.1.101 in /etc/network/interfaces.
Now what does `iface eth0 inet dhcp` ,especially dhcp ,mean here?
To assign my pc as a dhcp server for my home net?
Or assign my pc as a dhcp client?

Last edited by luofeiyu; 06-29-2016 at 07:17 AM.
 
Old 06-29-2016, 10:26 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,629
Blog Entries: 4

Rep: Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930
Please, stop and read the various responses that have already been given to you!

Each computer has exactly one IP-address, on the network to which it is attached. (Your internet router has two addresses, one for the "inside" network, the other on "the Internet.")

IP-addresses can be assigned in one of two ways: either they are fixed, or they are assigned by DHCP.

If you wish for DHCP to always assign a particular address to a particular computer, this is done in the setup-pages of the DHCP server (your router). Each hardware device has a unique serial number called a "MAC Address," and the router can be instructed to always assign a specific IP-address to that MAC.

If you specify an IP-address in your network-interfaces file, you should be sure that this address does not overlap the pool of addresses that is being handed-out by DHCP.
 
Old 06-29-2016, 10:30 AM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by luofeiyu View Post
Now what does `iface eth0 inet dhcp` ,especially dhcp ,mean here?
To assign my pc as a dhcp server for my home net?
Or assign my pc as a dhcp client?
It means your computer will request an IP address from the network's DHCP server (your router).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iscsid: discovery login to 192.168.130.101 rejected: initiator error (02/0b) AlucardZero Linux - Software 1 04-02-2010 03:08 PM
[root@wlxxb ~]# telnet 192.168.192.12 25 Trying 192.168.192.12... telnet problem cnhawk386 Linux - Networking 1 10-10-2007 02:50 PM
pinging 192.168.0.10 from 192.168.2.101 cov Linux - Networking 12 05-03-2007 10:21 AM
What route to access daisy chained 2d router 192.168.1.1 after 192.168.0.1 (subnets?) Emmanuel_uk Linux - Networking 6 05-05-2006 01:47 AM
Debian bound to IP address 192.168.0.101 when connected to D-link wireless router henrylcr Linux - Wireless Networking 4 01-28-2004 05:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration