我们先来看一下树梅派网卡的默认的相关配置:
网卡的配置文件:/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 //设置eth0的状态遵循手册 allow-hotplug wlan0 //允许-热插拔 wlan0 iface wlan0 inet manual //设置wlan0为状态遵循手册 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf //wpa协议文件的位置 allow-hotplug wlan1 //允许-热插拔 wlan1 iface wlan1 inet manual //设置wlan1为状态遵循手册 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf //wpa协议文件的位置
这个文件的网卡设置方式是方式是和dhcpcd一起使用的,如果要使用静态IP,请参考/etc/dhcpcd.conf和man dhcpcd.conf文件。
iface lo inet loopback 设置名称为lo的网卡,为本地回环
iface eth0 inet manual 设置名称为eth0的网卡,网卡服从本地的系统的默认配置文件:/etc/network/interfaces.dpkg-old
allow-hotplug wlan0 设置名称为wlan0的网卡,网卡的配置服从配置文件并支持热插拔:/etc/wpa_supplicant/wpa_supplicant.conf
静态配置文件:/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
eth0的默认配置手册:/etc/network/interfaces.dpkg-old
auto lo //自动获取 iface lo inet loopback //测试回路 iface eth0 inet dhcp //eth0的网络IP为dhcp(自动获取)
wlan0网卡配置文件:/etc/wpa_supplicant/wpa_supplicant.conf
country=GB ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1