Set Linux as router in one command. Support Internet sharing, redsocks, Wifi hotspot, IPv6. Can also be used for routing VM/containers 🛰️ (也欢迎关注B站 https://space.bilibili.com/2123686105 )
Use random LAN IPv4 address 192.168.255.1
Creating a virtual WiFi interface...
x0wlp2s0 created
Channel not specified, use default
Set x0wlp2s0 unmanaged by NetworkManager
Assigning MAC address c0:b6:f9:e2:64:cc to virtual interface x0wlp2s0 according to wlp2s0 ...
iptables v1.8.7 (nf_tables)
Notice: Not showing all operations done to iptables rules
haveged_watchdog PID: 2160978
Starting hostapd
hostapd PID: 2160983
x0wlp2s0: interface state UNINITIALIZED->ENABLED
x0wlp2s0: AP-ENABLED
./lnxrouter: line 1251: /proc/sys/net/ipv6/conf/x0wlp2s0/disable_ipv6: No such file or directory
iptables: NAT
MASQUERADE all opt -- in out !x0wlp2s0 192.168.255.0/24 !-> 192.168.255.0/24 / lrt2160813x0wlp2s0 /
ACCEPT all opt -- in x0wlp2s0 out 192.168.255.0/24 -> 0.0.0.0/0 / lrt2160813x0wlp2s0 /
ACCEPT all opt -- in out x0wlp2s0 0.0.0.0/0 -> 192.168.255.0/24 / lrt2160813x0wlp2s0 */
Loaded kernel module nf_nat_pptp
iptables: allow DNS
ACCEPT tcp opt -- in x0wlp2s0 out 192.168.255.0/24 -> 192.168.255.1 tcp dpt:53 / lrt2160813x0wlp2s0 /
ACCEPT udp opt -- in x0wlp2s0 out 192.168.255.0/24 -> 192.168.255.1 udp dpt:53 / lrt2160813x0wlp2s0 /
iptables: allow dhcp
ACCEPT udp opt -- in x0wlp2s0 out 0.0.0.0/0 -> 0.0.0.0/0 udp dpt:67 / lrt2160813x0wlp2s0 */
Starting dnsmasq
Apr 14 09:09:45 dnsmasq[2161498]: started, version 2.90 DNS disabled
Apr 14 09:09:45 dnsmasq[2161498]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset no-nftset auth cryptohash DNSSEC loop-detect inotify dumpfile
Apr 14 09:09:45 dnsmasq-dhcp[2161498]: DHCP, IP range 192.168.255.10 -- 192.168.255.250, lease time 1h
Apr 14 09:09:45 dnsmasq-dhcp[2161498]: DHCP, sockets bound exclusively to interface x0wlp2s0
dnsmasq PID: 2161498
Error org.freedesktop.DBus.Error.NameHasNoOwner: Could not get PID of name 'org.fedoraproject.FirewallD1': no such name
== Setting up completed, now linux-router should be working ==
`
Hi and many thanks for creating this script - on my system, it sometimes works but sometimes the AP is not visible and broadcasted.
I use the following command :
sudo ./lnxrouter --ap wlp2s0 "0ECF" -p xxx --dns 8.8.8.8 --no-dns --hs20
and have the following error :
./lnxrouter: line 1251: /proc/sys/net/ipv6/conf/x0wlp2s0/disable_ipv6: No such file or directory
and
Error org.freedesktop.DBus.Error.NameHasNoOwner: Could not get PID of name 'org.fedoraproject.FirewallD1': no such name
Any help to investigate ?
This is the output I get :
`linux-router 0.7.6b (https://github.com/garywill/linux-router) Released under LGPL, with no warranty. Use on your own risk.
PID: 2160813 Target interface is wlp2s0 (c0:b6:f9:e2:64:c2) PCI: 0000:02:00.0 System-already-loaded driver: iwlwifi Network controller [0280]: Intel Corporation Wireless 8265 / 8275 [8086:24fd] (rev 78)
Use random LAN IPv4 address 192.168.255.1 Creating a virtual WiFi interface... x0wlp2s0 created Channel not specified, use default Set x0wlp2s0 unmanaged by NetworkManager Assigning MAC address c0:b6:f9:e2:64:cc to virtual interface x0wlp2s0 according to wlp2s0 ...
iptables v1.8.7 (nf_tables) Notice: Not showing all operations done to iptables rules
haveged_watchdog PID: 2160978
Starting hostapd hostapd PID: 2160983 x0wlp2s0: interface state UNINITIALIZED->ENABLED x0wlp2s0: AP-ENABLED ./lnxrouter: line 1251: /proc/sys/net/ipv6/conf/x0wlp2s0/disable_ipv6: No such file or directory
iptables: NAT MASQUERADE all opt -- in out !x0wlp2s0 192.168.255.0/24 !-> 192.168.255.0/24 / lrt2160813x0wlp2s0 / ACCEPT all opt -- in x0wlp2s0 out 192.168.255.0/24 -> 0.0.0.0/0 / lrt2160813x0wlp2s0 / ACCEPT all opt -- in out x0wlp2s0 0.0.0.0/0 -> 192.168.255.0/24 / lrt2160813x0wlp2s0 */ Loaded kernel module nf_nat_pptp
iptables: allow DNS ACCEPT tcp opt -- in x0wlp2s0 out 192.168.255.0/24 -> 192.168.255.1 tcp dpt:53 / lrt2160813x0wlp2s0 / ACCEPT udp opt -- in x0wlp2s0 out 192.168.255.0/24 -> 192.168.255.1 udp dpt:53 / lrt2160813x0wlp2s0 /
iptables: allow dhcp ACCEPT udp opt -- in x0wlp2s0 out 0.0.0.0/0 -> 0.0.0.0/0 udp dpt:67 / lrt2160813x0wlp2s0 */
Starting dnsmasq Apr 14 09:09:45 dnsmasq[2161498]: started, version 2.90 DNS disabled Apr 14 09:09:45 dnsmasq[2161498]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset no-nftset auth cryptohash DNSSEC loop-detect inotify dumpfile Apr 14 09:09:45 dnsmasq-dhcp[2161498]: DHCP, IP range 192.168.255.10 -- 192.168.255.250, lease time 1h Apr 14 09:09:45 dnsmasq-dhcp[2161498]: DHCP, sockets bound exclusively to interface x0wlp2s0 dnsmasq PID: 2161498
Error org.freedesktop.DBus.Error.NameHasNoOwner: Could not get PID of name 'org.fedoraproject.FirewallD1': no such name
== Setting up completed, now linux-router should be working == `