[教程] 分享一篇debian配置DNS,静态网络,动态网络, 无线网络, 热点, pppoe拨号的配置文件模板

dns配置

vim /etc/resolv.conf
    nameserver <dns_addr>

静态/dhcp配置

vim /etc/network/interfaces
# 本地回环地址
auto lo
iface lo inet loopback
配置静态ip:
auto <interface>
iface <interface> inet static
  address <ipaddr>
  netmask <netmask>
  gateway <gateway>
配置DHCP获取ip:
auto <interface>
iface <interface> inet dhcp                                                            
iface <interface> inet6 dhcp

无线连接

1. 生成wpa_supplicant.conf配置文件
    wpa_passphrase "ssid_name" "password" > /etc/wpa_supplicant/wpa_suppliant.conf
2. 编辑/etc/wpa_supplicant/wpa_suppliant.conf 添加以下配置
    priority=1    # 优先级
    scan_ssid=1    # 扫描隐藏wifi
    示例:
    network={                                                                       
        ssid="ssid_name"
        #psk="password"
        psk="After encryption password"
        priority=1
        scan_ssid=1
    }

3. 修改interface文件
  # 本地回环地址
  auto lo
  iface lo inet loopback
  # 配置无线连接
  auto <interface>
  iface <interface> inet dhcp
  pre-up /sbin/ip link set up <interface>
  pre-up /sbin/wpa_supplicant -B -i <interface> -c /etc/wpa_supplicant/wpa_suppliant.conf
  pre-down /bin/kill -9 $(pgrep -n -x wpa_supplicant)

设置5G热点

1. hostapd 配置:
interface=<interface-name>
bridge=br0
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=<wifi-name>
country_code=CN
ieee80211d=1
ieee80211h=1
hw_mode=a
channel=36
beacon_int=100
dtim_period=2
max_num_sta=32
macaddr_acl=0
rts_threshold=2347
fragm_threshold=2346
wpa_passphrase=<密码>
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
rsn_pairwise=CCMP
wpa_key_mgmt=WPA-PSK
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40+][HT40-][SHORT-GI-20][SHORT-GI-40][MAX-AMSDU-7935]
ieee80211ac=1
vht_capab=[MAX-MPDU-11454][SHORT-GI-80][HTC-VHT][TX-STBC-2BY1][TX-STBC][RXLDPC]
vht_oper_chwidth=1
vht_oper_centr_freq_seg0_idx=42

2. 网卡配置:
  # 本地回环地址
  auto lo
  iface lo inet loopback

  # 桥接网口配置
  auto br0
  iface br0 inet static
    bridge_ports <interface1> <interface2> ...
    pre-up /sbin/hostapd /etc/hostapd/hostadp.conf -B
    post-up /usr/local/kea/sbin/keactrl reload
    pre-down /bin/kill -9 $(pgrep -n -x hostapd)
    address 172.20.1.1
    netmask 255.255.255.0

  auto <interface1>
  iface <interface1> inet manual

  auto <interface2>
  iface <interface2> inet manual

  ...

pppoe 拨号配置

1. 配置pppoe
  # 创建配置目录
  mkdir /etc/ppp/peers/

  # 编辑配置文件
  vim /etc/ppp/peers/dsl-provider
  noipdefault
  defaultroute
  replacedefaultroute
  hide-password
  lcp-echo-failure 20
  lcp-echo-interval 30
  noauth
  persist
  mtu 1492
  maxfail 0
  holdoff 0
  plugin rp-pppoe.so <interfacle_name>
  user "<user>"

  # 配置用户名密码
  vim /etc/ppp/chap-secrets
  "<user>" * "<password>"

  vim /etc/ppp/pap-secrets
  "<user>" * "<password>"

2. 网卡配置
  # loopback network interface
  auto lo
  iface lo inet loopback

  # pppoe network interface                                                         
  auto dsl-provider
  iface dsl-provider inet ppp
  pre-up /bin/ip link set <interface> up
  pre-down /bin/kill -9 $(pgrep -n -x pppd)
  post-down /bin/ip link set <interface> down
  provider dsl-provider

  # wan network interface                                                         
  auto <interface>
  iface <interface> inet manual