Skip to content

Commit 0ccdcf6

Browse files
committed
correct description about '--dhcp-dns(6)'
1 parent 61a5af2 commit 0ccdcf6

File tree

2 files changed

+50
-45
lines changed

2 files changed

+50
-45
lines changed

README.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@ Set Linux as router in one command. Able to Provide Internet, or create Wifi hot
44

55
It wraps `iptables`, `dnsmasq` etc. stuff. Use in one command, restore in one command or by `control-c` (or even by closing terminal window).
66

7-
[More tools and projects](https://garywill.github.io) | [🍻 Buy me a coffee ❤️](https://github.com/garywill/receiving/blob/master/receiving_methods.md)
7+
[More tools and projects 🛠️](https://garywill.github.io) | [🍻 Buy me a coffee ❤️](https://github.com/garywill/receiving/blob/master/receiving_methods.md)
88

99
## Features
1010

1111
Basic features:
1212

1313
- Create a NATed sub-network
1414
- Provide Internet
15-
- DHCP server and RA
16-
- DNS server
15+
- DHCP server (and RA) + DNS server
16+
- Configuring what DNS the DHCP server offers to clients
17+
- Configuring upstream DNS for local DNS server (kind of a DNS proxy)
1718
- IPv6 (behind NATed LAN, like IPv4)
1819
- Creating Wifi hotspot:
1920
- Channel selecting
2021
- Choose encryptions: WPA2/WPA, WPA2, WPA, No encryption
21-
- Create AP on the same interface you are getting Internet (require same channel)
22+
- Create AP on the same interface you are getting Internet (usually require same channel)
2223
- Transparent proxy (redsocks)
23-
- DNS proxy
24+
- Transparent DNS proxy (hijack port 53 packets)
2425
- Compatible with NetworkManager (automatically set interface as unmanaged)
2526

2627
**For many other features, see below [CLI usage](#cli-usage-and-other-features)**
@@ -62,21 +63,19 @@ Internet----(eth0/wlan0)-Linux-(virtual interface)-----VM/container
6263

6364
### Provide Internet to an interface
6465

65-
No matter which interface (other than `eth1`) you're getting Internet from
66-
6766
```
6867
sudo lnxrouter -i eth1
6968
```
7069

71-
### Create Wifi hotspot
70+
no matter which interface (other than `eth1`) you're getting Internet from.
7271

73-
No matter which interface you're getting Internet from (even from `wlan0`)
72+
### Create Wifi hotspot
7473

7574
```
7675
sudo lnxrouter --ap wlan0 MyAccessPoint -p MyPassPhrase
7776
```
7877

79-
It will create virtual Interface `x0wlan0` for hotspot.
78+
no matter which interface you're getting Internet from (even from `wlan0`). Will create virtual Interface `x0wlan0` for hotspot.
8079

8180
### Provide an interface's Internet to another interface
8281

@@ -88,10 +87,10 @@ Clients access Internet through only `isp5`
8887
sudo lnxrouter -i eth1 -o isp5 --no-dns --dhcp-dns 1.1.1.1 -6 --dhcp-dns6 [2606:4700:4700::1111]
8988
```
9089

91-
It's recommended to:
92-
93-
1. Stop serving local DNS to clients on our Linux host
94-
2. Tell clients which DNS to use (ISP5's DNS. Or, a safe public DNS, like above example)
90+
> In this case of usage, it's recommended to:
91+
>
92+
> 1. Stop serving local DNS
93+
> 2. Tell clients which DNS to use (ISP5's DNS. Or, a safe public DNS, like above example)
9594
9695
> Also, read *Notice 1*
9796
@@ -274,21 +273,22 @@ Options:
274273
and to provide Internet to
275274
(To create Wifi hotspot use '--ap' instead)
276275
-o <interface> Specify an inteface to provide Internet from.
276+
(See Notice 1)
277277
(Note using this with default DNS option may leak
278278
queries to other interfaces)
279279
-n Do not provide Internet (See Notice 1)
280280
--ban-priv Disallow clients to access my private network
281-
281+
282282
-g <ip> This host's IPv4 address in subnet (mask is /24)
283283
(example: '192.168.5.1' or '5' shortly)
284284
-6 Enable IPv6 (NAT)
285285
--no4 Disable IPv4 Internet (not forwarding IPv4)
286286
(See Notice 1). Usually used with '-6'
287-
287+
288288
--p6 <prefix> Set IPv6 LAN address prefix (length 64)
289289
(example: 'fd00:0:0:5::' or '5' shortly)
290290
Using this enables '-6'
291-
291+
292292
--dns <ip>|<port>|<ip:port>
293293
DNS server's upstream DNS.
294294
Use ',' to seperate multiple servers
@@ -298,35 +298,34 @@ Options:
298298
--no-dnsmasq Disable dnsmasq server (DHCP, DNS, RA)
299299
--catch-dns Transparent DNS proxy, redirect packets(TCP/UDP)
300300
whose destination port is 53 to this host
301-
--log-dns Show DNS query log
301+
--log-dns Show DNS query log (dnsmasq)
302302
--dhcp-dns <IP1[,IP2]>|no
303303
Set IPv4 DNS offered by DHCP (default: this host).
304-
This will enable '--no-dns' (Do not serve DNS)
305304
--dhcp-dns6 <IP1[,IP2]>|no
306305
Set IPv6 DNS offered by DHCP (RA)
307306
(default: this host)
308307
(Note IPv6 addresses need '[]' around)
309-
This will enable '--no-dns' (Do not serve DNS)
308+
Using both above two will enable '--no-dns'
310309
--hostname <name> DNS server associate this name with this host.
311310
Use '-' to read name from /etc/hostname
312311
-d DNS server will take into account /etc/hosts
313312
-e <hosts_file> DNS server will take into account additional
314313
hosts file
315-
314+
316315
--mac <MAC> Set MAC address
317316
--random-mac Use random MAC address
318-
317+
319318
--tp <port> Transparent proxy,
320319
redirect non-LAN TCP and UDP traffic to port.
321320
(usually used with '--dns')
322-
321+
323322
Wifi hotspot options:
324323
--ap <wifi interface> <SSID>
325324
Create Wifi access point
326325
-p, --password <password>
327326
Wifi password
328327
--qr Show Wifi QR code in terminal
329-
328+
330329
--hidden Hide access point (not broadcast SSID)
331330
--no-virt Do not create virtual interface
332331
Using this you can't use same wlan interface
@@ -345,12 +344,12 @@ Options:
345344
(defaults to /etc/hostapd/hostapd.accept)
346345
--hostapd-debug <level> 1 or 2. Passes -d or -dd to hostapd
347346
--isolate-clients Disable wifi communication between clients
348-
347+
349348
--ieee80211n Enable IEEE 802.11n (HT)
350349
--ieee80211ac Enable IEEE 802.11ac (VHT)
351350
--ht_capab <HT> HT capabilities (default: [HT40+])
352351
--vht_capab <VHT> VHT capabilities
353-
352+
354353
--no-haveged Do not run haveged automatically when needed
355354
356355
Instance managing:
@@ -366,7 +365,7 @@ Options:
366365
```
367366

368367
</details>
369-
368+
370369
## Notice
371370

372371
<details>
@@ -400,11 +399,11 @@ On exit of a linux-router instance, script **will do cleanup**, i.e. undo most c
400399
- dnsmasq
401400
- iptables (or nftables with `iptables-nft` translation linked)
402401
- WiFi hotspot dependencies
403-
- hostapd
404-
- iw
405-
- iwconfig (you only need this if 'iw' can not recognize your adapter)
406-
- haveged (optional)
407-
- qrencode (optional)
402+
- hostapd
403+
- iw
404+
- iwconfig (you only need this if 'iw' can not recognize your adapter)
405+
- haveged (optional)
406+
- qrencode (optional)
408407

409408
## TODO
410409

@@ -478,12 +477,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
478477

479478
## Meet developer(s) and become one of them
480479

481-
Visit [**my homepage**](https://garywill.github.io) to see **more tools and projects**.
480+
Visit [**my homepage** 🏡](https://garywill.github.io) to see **more tools and projects** 🛠️.
482481

483-
> [Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) , this project took me lots of time! ([打赏一个!](https://github.com/garywill/receiving/blob/master/receiving_methods.md))
482+
> [❤️ Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) , this project took me lots of time! ([❤️ 打赏一个!](https://github.com/garywill/receiving/blob/master/receiving_methods.md))
484483
>
485484
> 🥂 ( ^\_^) o自自o (^_^ ) 🍻
486485
487486
🤝 Bisides, thank [create_ap](https://github.com/oblique/create_ap) by [oblique](https://github.com/oblique). This script was forked from create\_ap. Now they are quite different. (See `history` branch for how I modified create_ap). 🤝 Also thank those who contributed to that project.
488487

489-
🤝 You can be contributor, too! There're some TO-DOs listed, at both above and in the code file. Your name can be here!
488+
👨‍💻 You can be contributor, too! 🍃 There're some TO-DOs listed, at both above and in the code file. Also some unfulfilled enhancements in the Issues. Your name can be here!

lnxrouter

100755100644
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ umask $SCRIPT_UMASK
1111
phead() {
1212
echo "linux-router $VERSION (https://github.com/garywill/linux-router)"
1313
}
14+
phead2() {
15+
echo "Released under LGPL, with no warranty. Use on your own risk."
16+
}
1417
usage() {
1518
phead
19+
phead2
1620
cat << EOF
17-
Released under LGPL, with no warranty. Use on your own risk.
1821
1922
Usage: $PROGNAME <options>
2023
@@ -26,6 +29,7 @@ Options:
2629
and to provide Internet to
2730
(To create Wifi hotspot use '--ap' instead)
2831
-o <interface> Specify an inteface to provide Internet from.
32+
(See Notice 1)
2933
(Note using this with default DNS option may leak
3034
queries to other interfaces)
3135
-n Do not provide Internet (See Notice 1)
@@ -50,15 +54,14 @@ Options:
5054
--no-dnsmasq Disable dnsmasq server (DHCP, DNS, RA)
5155
--catch-dns Transparent DNS proxy, redirect packets(TCP/UDP)
5256
whose destination port is 53 to this host
53-
--log-dns Show DNS query log
57+
--log-dns Show DNS query log (dnsmasq)
5458
--dhcp-dns <IP1[,IP2]>|no
5559
Set IPv4 DNS offered by DHCP (default: this host).
56-
This will enable '--no-dns' (Do not serve DNS)
5760
--dhcp-dns6 <IP1[,IP2]>|no
5861
Set IPv6 DNS offered by DHCP (RA)
5962
(default: this host)
6063
(Note IPv6 addresses need '[]' around)
61-
This will enable '--no-dns' (Do not serve DNS)
64+
Using both above two will enable '--no-dns'
6265
--hostname <name> DNS server associate this name with this host.
6366
Use '-' to read name from /etc/hostname
6467
-d DNS server will take into account /etc/hosts
@@ -124,7 +127,6 @@ Options:
124127
125128
Examples:
126129
$PROGNAME -i eth1
127-
$PROGNAME --ap wlan0 MyAccessPoint
128130
$PROGNAME --ap wlan0 MyAccessPoint -p MyPassPhrase
129131
$PROGNAME -i eth1 --tp <transparent-proxy> --dns <dns-proxy>
130132
EOF
@@ -821,7 +823,7 @@ check_iptables()
821823
iptables --version
822824

823825
if which firewall-cmd > /dev/null 2>&1; then
824-
if [[ "$(firewall-cmd --state)" == "running" ]]; then
826+
if [[ "$(firewall-cmd --state 2>&1)" == "running" ]]; then
825827
echo "firewalld is running ($(firewall-cmd --version))"
826828
echo -e "\nWARN: We haven't completed the compatibility with firewalld.\nWARN: If you see any trouble, try:\nWARN: 1) 'firewall-cmd --zone=trusted --add-interface=<SUBN_IFACE>'\nWARN: 2) disable firewalld\n" >&2
827829
# TODO
@@ -887,6 +889,7 @@ start_ban_lan() {
887889
echo
888890
echo "iptables: Disallow clients to access LAN"
889891
iptables_ -N BANLAN-f-${SUBNET_IFACE} || die
892+
# TODO: allow '--dhcp-dns(6)' address port 53, which can be something needed, e.g. a VPN's internal private IP
890893
iptables_ -v -I BANLAN-f-${SUBNET_IFACE} -d 0.0.0.0/8 -j REJECT || die # TODO: use array
891894
iptables_ -v -I BANLAN-f-${SUBNET_IFACE} -d 10.0.0.0/8 -j REJECT || die
892895
iptables_ -v -I BANLAN-f-${SUBNET_IFACE} -d 100.64.0.0/10 -j REJECT || die
@@ -902,7 +905,7 @@ start_ban_lan() {
902905
iptables_ -N BANLAN-i-${SUBNET_IFACE}
903906
#iptables_ -v -I BANLAN-i-${SUBNET_IFACE} -i ${SUBNET_IFACE} -j REJECT || die
904907
iptables_ -v -I BANLAN-i-${SUBNET_IFACE} -i ${SUBNET_IFACE} ! -p icmp -j REJECT || die
905-
# TODO: ipv6 need icmp to function. maybe we can block some unneeded icmp to improve security
908+
# ipv6 need icmp to function. TODO: maybe we can block some unneeded icmp to improve security
906909

907910
iptables_ -I INPUT -i ${SUBNET_IFACE} -j BANLAN-i-${SUBNET_IFACE} || die
908911

@@ -1153,7 +1156,7 @@ kill_processes() { # for this instance
11531156
pn=$( ps -p $pid -o comm= )
11541157
#echo "Killing $pid $pn ... "
11551158
pkill -P $pid
1156-
kill $pid 2>/dev/null && ( echo "Killed $pid $pn" && rm $x ) || echo "Failed to kill $pid $pn, it may have exited"
1159+
kill $pid 2>/dev/null && ( echo "Killed $(basename $x) $pid $pn" && rm $x ) || echo "Failed to kill $(basename $x) $pid $pn, it may have exited"
11571160
fi
11581161
done
11591162
}
@@ -1968,6 +1971,9 @@ daemonizing_check
19681971
## ===== Above don't echo anything if no warning or error====================
19691972
## ========================================================
19701973
phead
1974+
phead2
1975+
echo
1976+
19711977
echo "PID: $$"
19721978

19731979
TARGET_IFACE="$(decide_target_interface)" || exit 1 # judge wired (-i CONN_IFACE) or wireless hotspot (--ap $WIFI_IFACE)
@@ -2060,7 +2066,7 @@ if [[ "$SHARE_METHOD" == "none" ]]; then
20602066

20612067
elif [[ "$SHARE_METHOD" == "nat" ]]; then
20622068

2063-
[[ "$INTERNET_IFACE" && "$dnsmasq_NO_DNS" -eq 0 ]] && echo -e "\nWARN: You specified Internet interface but this host is providing local DNS, queries may leak to other interfaces!!!\n" >&2
2069+
[[ "$INTERNET_IFACE" && "$dnsmasq_NO_DNS" -eq 0 ]] && echo -e "\nWARN: You specified Internet interface but this host is providing local DNS. In some unexpected case (eg. mistaken configurations), queries may leak to other interfaces, which you should be aware of.\n" >&2
20642070

20652071
start_nat
20662072

@@ -2082,7 +2088,7 @@ elif [[ "$SHARE_METHOD" == "redsocks" ]]; then
20822088
echo 1 > "/proc/sys/net/ipv6/conf/$SUBNET_IFACE/forwarding" || die "Failed enabling $SUBNET_IFACE ipv6 forwarding" # to set NA router bit
20832089
fi
20842090

2085-
[[ "$dnsmasq_NO_DNS" -eq 0 && ! $DNS ]] && echo -e "\nWARN: You are using in transparent proxy mode but this host is providing local DNS, this may cause privacy leak !!!\n" >&2
2091+
[[ "$dnsmasq_NO_DNS" -eq 0 && ! $DNS ]] && echo -e "\nWARN: You are using in transparent proxy mode but this host is providing local DNS. In some unexpected case (eg. mistaken configurations), queries may leak to other interfaces, which you should be aware of.\n" >&2
20862092

20872093
[[ "$BANLAN" -eq 1 ]] && start_ban_lan
20882094

0 commit comments

Comments
 (0)