假使將問題輕輕放過,久而久之必模模糊糊,不知來去矣!!於是乎考之以樹莓派論壇,聽聽人們的經驗談,看看解決嘗試的方向︰
Configuring Network using dhcpcd
I have read the `dhcpcd` and `interfaces` `man` pages but these do not seem to apply to the actual interface.The `/etc/network/interfaces` used to contain `iface eth0 inet dhcp` which has been replaced by `iface eth0 inet manual`Where does the IP address come from? This seems to allocate the same IP reservation from my router.(I am trying to work out a configuration which will let my Pi work normally with dhcp on my home network, but allocate a `static` address so I can connect to the Pi over Ethernet (or ad-hoc WiFi) to my Mac in a remote environment with no router or internet access.)
……
morgon wrote:Maybe I don’t understand your posting (and I may have one beer too many)
How many is too many?
The new dhcpd seems to ignore the normal /etc/network/interfaces settings and just do its own thing. I might have a look at the reasoning for this and how to configure it one day, but for now I’m sticking with the old one that has worked since forever.
(I think the new one may need some GUI stuff to configure it? I run headless, so no idea)
───
Set Static IP address but also getting Dynamic
This problem was plaguing me for ages. dhcpcd5 simply seems to ignore the interfaces file so you have to set exclusions in the dhcpcd.conf file. Really quick and easy to do.
Try adding the line:
denyinterfaces eth0
to /etc/dhcpcd.conf (change eth0 as required).
No need to make any extra changes in /etc/network/interfaces or uninstall anything.
man dhcpcd.conf for more info.
Sorry if I missed someone else posting this already or within a link to another post.
Kez
───
縱使有時某甲有用之法,某乙用之無效??至少可觀錯綜複雜脈絡也。因此在仔細閱讀 dhcpcd5 文件後︰
DHCPCD.CONF(5) BSD File Formats Manual DHCPCD.CONF(5) NAME dhcpcd.conf — dhcpcd configuration file DESCRIPTION Although dhcpcd can do everything from the command line, there are cases where it's just easier to do it once in a configuration file. Most of the options found in dhcpcd(8) can be used here. The first word on the line is the option and the rest of the line is the value. Leading and trailing whitespace for the option and value are trimmed. You can escape characters in the value using the \ character. Blank lines and lines starting with # are ignored. Here's a list of available options: allowinterfaces pattern When discovering interfaces, the interface name must match pattern which is a space or comma separated list of patterns passed to fnmatch(3). If the same interface is matched in denyinterfaces then it is still denied. Manual page dhcpcd.conf(5) line 1 (press h for help or q to quit)
決定只用 dhcpcd5 程式來管理網路裝置︰
cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and ‘man dhcpcd.conf’
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
# allow-hotplug wlan1
# iface wlan1 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
cat /etc/dhcpcd.conf
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
interface wlan1
static ip_address=192.168.8.1/24
static routers=192.168.8.1
static domain_name_servers=192.168.8.1
似乎一切正常哩!!
pi@raspberrypi:~
誰知其他電腦卻連不上耶??