如果設想以『中』字為觀,其中『一豎』就是文本,而那個『□』── 框 ──,就是當下所『觀』。人的眼界受限於框,就像編輯軟體也有個『視窗』一般。術語上,編輯軟體的這個視窗叫做『文本窗口』text window。在這個框中,一個一個『文字符號』,依序排列,可以用著『行列』定位,以至我們可以說哪個字在哪行哪列。人們的目光總有個『焦點』,聚焦在一個特定的『位置』,就是編輯軟體上的『游標』,指示著現下的『這個字』。如此說來,一個編輯軟體需要提供哪些『功能』去完成『新創』或『修改』文本,也就不難設想了。有人說,這個行列的想法,大概只適合文字界面吧,要是圖形界面的話,比方說眼前的『這篇』文章,就更本不適用。其實你只要把行列的概念,推廣成笛卡爾的座標系就行了。這樣你可以用『點定位』的不只是文字,它是圖形又何妨。然而裡頭基本的想法還是一樣的。對今天的使用者來說,『所見即所得』的文字處理程式想法,一點也不會陌生,它會『排版』而且能『呈現』出一樣的所得之所見到各種輸出裝置 ──『螢幕』、『印表機』、『網頁』…──。那麽一個簡單的文本編輯軟體又怎麽看待文本的『排版』呢?標點符號標示著文句的意義,卻不代表著最終呈現出的『一行』或是『一列』,比如說『詩詞』上斷開句子的文意呈現。所以就需要一個方法來處理排版上的這個『換行』── 排版上的『分界』,這是一行的終結 End Of Line,另一行將起『新行』符號的由來。然而這個控制符號卻引起了一場史稱『Teletype Model 33 ASR』事件︰
傳說於 1963 年時,這台電動打字機,打字頭由行末回到行首── 回車 Carriage Return ── 需要它打『兩個字』的時間,而移動紙張的滾輪,移動一行距離 Line Feed,只需『一個字』的時間,所以軟體程式設計師為了配合著它的運作節奏,只得用 EOL = CR + LF 剛好兩個字的時間,來標示排版上的新行符號。
此後,到底該用什麼代表 EOL 就各吹各的調了。直到如今頻果的 CR、\r,微軟的 CR+LF、\r\n,以及 Unix 的 LF、\n,成為三種主流,持續影響著文本於不同作業系統間的往來時,都必須要轉換 EOL 符號一事。雖然許多『跨平台』的軟體,比方騛罿 Python 讀檔案時能自動轉換,對於可執行的文本命令檔來說,最好還是注意這個問題。如果你稍稍留意,這些又稱作 ASCII 控制碼的 CR 和 LF 符號,在文本編輯時是『看不見』的,它的作用是文本呈現的『控制』,並不屬於文本的『文義』之中,雖然用於排版時,或表現出作者對『美觀』的要求,因有著一定『風格』的意思。由於它的『看不見』,作用又有點像『文言虛詞』,在一般程式語言裡稱這些看不見的叫做 white-space,或許可以譯作『留白』。
nano 短小精練的文本編輯程式,非常合適在終端機命令列上使用,作者志在取代 pico ,曾說︰完全『錯映錯』bug-for-bug 般的模擬著相容於 pico。就像傳聞 Wine 的作者們 ── 在 Linux 上跑 Windows 程式的模擬器 ── 當被問到『為什麼』某某軟體不能跑時,回答的感慨一樣︰看來我們只能製造『相同的錯誤』,才能解決這個問題。是為求問題解決,不得不吞下的這杯苦酒!!奈文編輯器 nano text editor 的完整使用者文件,可以到使用 nano 文本編輯器之處閱讀,在此我們將只介紹於 Raspbian 上的基本用法︰
……
─── 《刀筆契刻︰NANO 編輯》
『學習』故應從讀
User Guide
General Information for Using LEDE
-
Switch vs. Router vs. Gateway. Find out, how you want to run your OpenWrt/LEDE device and how IPv4 NAT affects this decision.
-
WiFi regulation information and the country code for OpenWrt/LEDE’s WiFi operation. Some background information about country-specific WiFi limits
-
Security and hardening. General things about OpenWrt/LEDE security, patching, hardening and responsibilities of a OpenWrt/LEDE admin
Basic configuration
Documentation
User Guide
Base system
- Basic Configuration
- Command-line interpreter
- Cron and crontab
- DHCP
- DNS and DHCP configuration /etc/config/dhcp
- DNS configuration
- Dnsmasq
- Dropbear Configuration
- Dynamic DNS Client configuration
- Hotplug
- LED configuration /etc/config/system
- Managing system services
- Network basics /etc/config/network
- Runtime Logging in OpenWrt
- SSH Configuration
- System configuration /etc/config/system
- System configuration not handled by UCI
- The UCI System
- User Configuration
- Web Server Configuration
………
開始。然而一大堆艱深的『術語』,眾多不知名『選項』,恐為難新手也!
看看所謂『基本』之家用『路由器』︰
Network basics /etc/config/network
-
This is an default LEDE network stack of a typical home router
-
your device may vary slightly in features or numbering scheme
-
Pay attention, that the labels “WAN” and “LAN” can mean different things, depending on their context
LuCi web GUI | Comment | ||||||||
---|---|---|---|---|---|---|---|---|---|
“Firewall” | Rules for traffic between zones | Forwarding Rules, Traffic Rules, Custom Rules | |||||||
“Firewall”, “Interfaces” | Network zone configuration | WAN (Zone) | LAN (Zone) | ||||||
“Interfaces” | TCP config & Bridge configuration | WAN | WAN6 | LAN (TCP and Bridge config) | |||||
“Switch”, “Wireless” | VLANs and wireless SSIDs | VLAN 1 (eth 0.2) | VLAN 2 (eth 0.1) | LEDE 5 | LEDE 2.4 | ||||
“Switch”, “Wireless” | Internal jack labels and radio labels | WAN (Interface) | LAN 1 | LAN 2 | LAN 3 | LAN 4 | radio0 | radio1 | |
– | Common vendor labels on backside a device | “Internet” | “1” | “2” | “3” | “4” | “n/ac” | “b/g/n” |
ㄌ一ㄉㄡ 宰羊?
所以先給個『橋接式』
wan ─── lan ─── ap
文稿範例︰
root@LEDE:~# cat /etc/config/network
config interface ‘loopback’
option ifname ‘lo’
option proto ‘static’
option ipaddr ‘127.0.0.1’
option netmask ‘255.0.0.0’
config globals ‘globals’
option ula_prefix ‘fde4:7479:7f71::/48’
config interface ‘lan’
option type ‘bridge’
option proto ‘static’
option ipaddr ‘5.168.166.88’
option netmask ‘255.255.255.0’
option ip6assign ’60’
config interface ‘wan’
option type ‘bridge’
option proto ‘dhcp’
option ifname ‘eth0’
option peerdns ‘0’
option dns ‘8.8.8.8’
───
root@LEDE:~# cat /etc/config/wireless
config wifi-device ‘radio0’
option type ‘mac80211’
option channel ’11’
option hwmode ’11g’
option path ‘platform/soc/3f300000.mmc/mmc_host/mmc1/mmc1:0001/mmc1:0001:1’
option htmode ‘HT20’
option disabled ‘0’
config wifi-iface ‘default_radio0’
option device ‘radio0’
option network ‘lan’
option mode ‘ap’
option ssid ‘LEDE-RPI-3B’
option encryption ‘psk2+ccmp’
option key ‘12345678’
───
add the following to /etc/config/firewall
#open ssh on wan interface
config rule
option src wan
option dest_port 22
option target ACCEPT
option proto
#open web on wan interface
config rule
option src wan
option dest_port 80
option target ACCEPT
option proto
希望讀者『刀筆契刻』一下,打造自己的『學習環境』☺
※ 註︰
‧ nano 安裝
opkg update
opkg install nano
‧為什麼需要 ssh 、 web 『防火牆』設定︰
Client Device – Connecting to an existing network
OpenWrt will provide additional functions for the network (for example, you just want to use the Wi-Fi network it provides, or the device is a NAS serving files over the network, or a mini-server offering whatever other service).
This means:
-
the other router will provide DHCP services to your network (DHCP server will be turned off)
-
the device’s network firewall will be off, such that e.g. wired devices connected to the other router can contact e.g. wireless devices connected to the OpenWrt router
Luci instructions:
-
Click on Network → Interfaces, then click on the Edit button of the LAN Network.
-
In General Setup tab, in Protocol, select Static Address
-
In IPv4 address write the new static address of this device, if your old router’s address is 192.168.1.1 (most common) and there are no other devices with static addresses on your network (also the most common situation for home networks) you can usually choose any address from 192.168.1.2 to 192.168.1.250. Once you have chosen and written the IP address, write it down in the same sticker with the user/password above, it will be used to connect to your device in the future.
-
in IPv4 Netmask select the same netmask as set in your old router’s Lan/ethernet settings, it is (very) usually 255.255.255.0
-
in IPv4 gateway write the address of the gateway, the device that allows internet access in your local network. In most home networks, the old router is the gateway too, and its default address is 192.168.1.1.
-
Set the DNS in the Custom DNS field. A DNS is a server used to translate human-readable website names (like “www.google.com”) into their actual IP address. In most cases you should write there the address of the local network’s router/gateway (that acts as local DNS), so 192.168.1.1, or the address of an actual DNS server in the internet, for example 8.8.8.8 that is the address of Google’s DNS servers.
-
Scroll down and in DHCP Server, in General tab, select “Disable DHCP for this interface”, to disable automatic IP assignment on the LAN. Client devices will be connected to a network where there is a router doing DHCP server already and this will avoid conflicts with it.
-
Setting DHCP Client in the Protocol field will allow you to skip all of the above in most cases, but a device set like that will have an IP that changes depending on the current network router’s decisions, so any time you need to connect to it you need to find its current IP first, which may be easy or not depending on the router’s web interface or other networking tools you have on your PC/smartphone. This option is not recommended, as it makes connecting with the device unnecessarily more complex.
-
When you are done, click on Save & Apply button at the end of the page. This will change the network configuration of the device, and will now be accessible at the IP you set above (or at an unknown dynamic IP if you used “DHCP client option”), so the current page you used for configuring it will fail to connect to the device. Disconnect the cable from the PC and connect it to the current network router’s Lan ethernet ports, write the IP address in your browser’s address bar and you should be able to connect to it again as normal.
Command line instructions to make the same we just did with Luci webinterface above, see above for more detailed explanation of the steps:
-
type
uci set network.lan.ipaddr='new-ip-address
‘ and press Return -
type
uci set network.lan.gateway='your-gateway-address
‘ and press Return -
type
uci set network.lan.dns='dns-address-here
‘ and press Return -
type
uci commit && service network restart
(this will save the changes and restart network interfaces) -
the ssh session will not work anymore because the device has changed address, this is normal
-
now you can connect the network cable from the device’s LAN port to your existing network (the other router’s LAN ports usually)
-
connect again to the device at its new address as defined above
知道 wan 、 lan 『定義』來自何方︰
/etc/config/firewall
……
config zone
option name lan
list network ‘lan’
option input ACCEPT
option output ACCEPT
option forward ACCEPT
config zone
option name wan
list network ‘wan’
list network ‘wan6’
option input REJECT
option output ACCEPT
option forward REJECT
option masq 1
option mtu_fix 1
config forwarding
option src lan
option dest wan
………
方便藉著『老』實務︰
一位善長『實務』的人,能不善用『工具』耶?!
倘伊止於聲聞,果可得門徑嘛!?
Linux Foundation Wiki
project collaboration site
Trace: • net-tools
Overview
A collection of programs that form the base set of the NET-3 networking distribution for the Linux operating system. This package includes arp(8), hostname(1), ifconfig(8), ipmaddr, iptunnel, mii-tool(8), nameif(8), netstat(8), plipconfig(8), rarp(8), route(8) and slattach(8).
-
Maintainers: Bernd Eckenfels, Phil Blundell
-
Current Version: net-tools 1.60 http://net-tools.sf.net/
Please keep in mind that most net-tools programs are obsolete now:
PROGRAM | OBSOLETED BY |
---|---|
arp | ip neigh |
ifconfig | ip addr |
ipmaddr | ip maddr |
iptunnel | ip tunnel |
route | ip route |
nameif | ifrename |
mii-tool | ethtool |
You would probably want to review iproute2 page. See also net-tools future thread.
『術』即使早學,有時望洋興嘆哩!★
─── 摘自《樹莓派 3B+ 筦窺︰ GIGABIT ︰ 300MBIT !認識工具‧上》
root@LEDE:~# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-wan state UP qlen 1000 link/ether b8:27:eb:c2:b0:6e brd ff:ff:ff:ff:ff:ff 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UP qlen 1000 link/ether b8:27:eb:97:e5:3b brd ff:ff:ff:ff:ff:ff inet6 fe80::ba27:ebff:fe97:e53b/64 scope link valid_lft forever preferred_lft forever 4: br-wan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000 link/ether b8:27:eb:c2:b0:6e brd ff:ff:ff:ff:ff:ff inet 5.168.168.9/24 brd 5.168.168.255 scope global br-wan valid_lft forever preferred_lft forever inet6 fe80::ba27:ebff:fec2:b06e/64 scope link valid_lft forever preferred_lft forever 5: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000 link/ether b8:27:eb:97:e5:3b brd ff:ff:ff:ff:ff:ff inet 5.168.166.88/24 brd 5.168.166.255 scope global br-lan valid_lft forever preferred_lft forever inet6 fde4:7479:7f71::1/60 scope global valid_lft forever preferred_lft forever inet6 fe80::ba27:ebff:fe97:e53b/64 scope link valid_lft forever preferred_lft forever
root@LEDE:~# ip route default via 5.168.168.1 dev br-wan src 5.168.168.9 5.168.166.0/24 dev br-lan src 5.168.166.88 5.168.168.0/24 dev br-wan src 5.168.168.9 5.168.168.1 dev br-wan src 5.168.168.9
及『新』工具︰
BRCTL(8) BRCTL(8) NAME brctl - ethernet bridge administration SYNOPSIS brctl [command] DESCRIPTION brctl is used to set up, maintain, and inspect the ethernet bridge con‐ figuration in the linux kernel. An ethernet bridge is a device commonly used to connect different net‐ works of ethernets together, so that these ethernets will appear as one ethernet to the participants. Each of the ethernets being connected corresponds to one physical interface in the bridge. These individual ethernets are bundled into one bigger ('logical') ethernet, this bigger ethernet corresponds to the bridge network interface.
root@LEDE:~# brctl show bridge name bridge id STP enabled interfaces br-wan 7fff.b827ebc2b06e no eth0 br-lan 7fff.b827eb97e53b no wlan0
認識『網際網路』果真汪洋呦◎