Compare commits

..

No commits in common. "a663d9052b2907cf36daeafbd04426876969e256" and "a414ac035b3bc8edbdac594fc49f5eed185a2f70" have entirely different histories.

2 changed files with 31 additions and 45 deletions

View File

@ -138,7 +138,7 @@ sudo lnxrouter -i lxcbr5
### Transparent proxy ### Transparent proxy
All clients' Internet traffic go through, for example, Tor (notice this example is NOT an anonymity use) All clients' Internet traffic go through, for example, Tor
<details> <details>
@ -155,10 +155,6 @@ TransPort [fd00:5:6:7::1]:9040
DNSPort [fd00:5:6:7::1]:9053 DNSPort [fd00:5:6:7::1]:9053
``` ```
> **Warn**: Tor's anonymity relies on a purpose-made browser. Using Tor like this (sharing Tor's network to LAN clients) will NOT ensure anonymity.
>
> Although we use Tor as example here, Linux-router does NOT ensure nor is NOT aiming at anonymity.
</details> </details>
### Clients-in-sandbox network ### Clients-in-sandbox network
@ -177,7 +173,7 @@ sudo lnxrouter -i eth1 \
</details> </details>
> Linux-router comes with no warranty. Use on your own risk > This script comes with no warrenty. Use on your own risk
### Use as transparent proxy for LXD ### Use as transparent proxy for LXD
@ -327,8 +323,8 @@ Options:
--random-mac Use random MAC address --random-mac Use random MAC address
--tp <port> Transparent proxy, --tp <port> Transparent proxy,
redirect non-LAN TCP and UDP(not tested) traffic to redirect non-LAN TCP and UDP traffic to port.
port. (usually used with '--dns') (usually used with '--dns')
WiFi hotspot options: WiFi hotspot options:
--ap <wifi interface> <SSID> --ap <wifi interface> <SSID>
@ -341,7 +337,6 @@ Options:
--no-virt Do not create virtual interface --no-virt Do not create virtual interface
Using this you can't use same wlan interface Using this you can't use same wlan interface
for both Internet and AP for both Internet and AP
--virt-name <name> Set name of virtual interface
-c <channel> Channel number (default: 1) -c <channel> Channel number (default: 1)
--country <code> Set two-letter country code for regularity --country <code> Set two-letter country code for regularity
(example: US) (example: US)

View File

@ -73,8 +73,8 @@ Options:
--random-mac Use random MAC address --random-mac Use random MAC address
--tp <port> Transparent proxy, --tp <port> Transparent proxy,
redirect non-LAN TCP and UDP(not tested) traffic to redirect non-LAN TCP and UDP traffic to port.
port. (usually used with '--dns') (usually used with '--dns')
WiFi hotspot options: WiFi hotspot options:
--ap <wifi interface> <SSID> --ap <wifi interface> <SSID>
@ -87,7 +87,7 @@ Options:
--no-virt Do not create virtual interface --no-virt Do not create virtual interface
Using this you can't use same wlan interface Using this you can't use same wlan interface
for both Internet and AP for both Internet and AP
--virt-name <name> Set name of virtual interface --virt-name <name> Naming convension for virtual interface
-c <channel> Channel number (default: 1) -c <channel> Channel number (default: 1)
--country <code> Set two-letter country code for regularity --country <code> Set two-letter country code for regularity
(example: US) (example: US)
@ -198,7 +198,7 @@ define_global_variables(){
# script variables # script variables
VWIFI_IFACE= # virtual wifi interface name, if created VWIFI_IFACE= # virtual wifi interface name, if created
VIRT_NAME= # name to use for virtual interface if --virt-name is used VIRT_PREFIX= # prefix to use for naming virtual interface
AP_IFACE= # can be VWIFI_IFACE or WIFI_IFACE AP_IFACE= # can be VWIFI_IFACE or WIFI_IFACE
USE_IWCONFIG=0 # some device can't use iw USE_IWCONFIG=0 # some device can't use iw
@ -409,7 +409,7 @@ parse_user_options(){
;; ;;
--virt-name) --virt-name)
shift shift
VIRT_NAME="$1" VIRT_PREFIX="$1"
shift shift
;; ;;
@ -518,10 +518,6 @@ is_interface() {
[[ -d "/sys/class/net/${1}" ]] [[ -d "/sys/class/net/${1}" ]]
} }
is_vface_name_allocated(){
is_interface "$1" || [[ -f "$COMMON_CONFDIR/vfaces/${1}" ]]
}
get_interface_phy_device() { # only for wifi interface get_interface_phy_device() { # only for wifi interface
local x local x
for x in /sys/class/ieee80211/*; do for x in /sys/class/ieee80211/*; do
@ -668,19 +664,24 @@ get_interface_pci_info() { # pci id / model / virtual
# TODO current driver # TODO current driver
} }
alloc_new_vface_name() { # only for wifi alloc_new_vface_name() { # only for wifi
local i=0 local i=0
local v_iface_name="$VIRT_NAME" local v_iface_name=
if [[ -z $VIRT_NAME ]]; then
while :; do while :; do
if [[ -z $VIRT_PREFIX ]]; then
v_iface_name="x$i${WIFI_IFACE}" v_iface_name="x$i${WIFI_IFACE}"
i=$((i + 1)) else
is_vface_name_allocated ${v_iface_name} || break v_iface_name="$VIRT_PREFIX$i"
done
fi fi
if ! is_interface ${v_iface_name} && [[ ! -f $COMMON_CONFDIR/vfaces/${v_iface_name} ]]; then
mkdir -p $COMMON_CONFDIR/vfaces mkdir -p $COMMON_CONFDIR/vfaces
touch $COMMON_CONFDIR/vfaces/${v_iface_name} touch $COMMON_CONFDIR/vfaces/${v_iface_name}
echo "${v_iface_name}" echo "${v_iface_name}"
return
fi
i=$((i + 1))
done
} }
dealloc_vface_name() { dealloc_vface_name() {
@ -1037,7 +1038,7 @@ allow_dhcp() {
# TODO: use 'DNAT' instead of '--to-ports' to support other IP # TODO: use 'DNAT' instead of '--to-ports' to support other IP
start_redsocks() { start_redsocks() {
echo echo
echo "iptables: transparent proxy non-LAN TCP and UDP(not tested) traffic to port ${TP_PORT}" echo "iptables: transparent proxy non-LAN TCP/UDP traffic to port ${TP_PORT}"
if [[ $NO4 -eq 0 ]]; then if [[ $NO4 -eq 0 ]]; then
iptb 4 n nat N lrt${$}${SUBNET_IFACE}-TP || die iptb 4 n nat N lrt${$}${SUBNET_IFACE}-TP || die
iptb 4 n nat A lrt${$}${SUBNET_IFACE}-TP -d 0.0.0.0/8 -j RETURN || die iptb 4 n nat A lrt${$}${SUBNET_IFACE}-TP -d 0.0.0.0/8 -j RETURN || die
@ -1223,7 +1224,7 @@ cleanup() {
#kill -9 -$pgid #kill -9 -$pgid
} }
# NOTE function die() is designed NOT to be used before init_trap() executed # NOTE function die() is designed not to be used before init_trap() executed
die() { # SIGUSR2 die() { # SIGUSR2
echo "Error occured" echo "Error occured"
[[ -n "$1" ]] && echo -e "\nERROR: $1\n" >&2 [[ -n "$1" ]] && echo -e "\nERROR: $1\n" >&2
@ -1586,16 +1587,12 @@ check_wifi_settings() {
echo "WARN: If AP doesn't work, read https://github.com/oblique/create_ap/blob/master/howto/realtek.md" >&2 echo "WARN: If AP doesn't work, read https://github.com/oblique/create_ap/blob/master/howto/realtek.md" >&2
fi fi
if [[ -z $VIRT_NAME ]]; then if [[ -z $VIRT_PREFIX ]]; then
if [[ ${#WIFI_IFACE} -gt 13 ]]; then if [[ ${#WIFI_IFACE} -gt 13 ]]; then
echo "WARN: $WIFI_IFACE has ${#WIFI_IFACE} characters which might be too long. If AP doesn't work, see --virt-name and https://github.com/garywill/linux-router/issues/44" >&2 echo "WARN: $WIFI_IFACE has ${#WIFI_IFACE} characters which might be too long. If AP doesn't work, see --virt-name and https://github.com/garywill/linux-router/issues/44" >&2
fi fi
elif [[ ${#VIRT_NAME} -gt 15 ]]; then elif [[ ${#VIRT_PREFIX} -gt 14 ]]; then
echo "WARN: option --virt-name $VIRT_NAME has ${#VIRT_NAME} characters which might be too long, consider making it shorter in case of errors" >&2 echo "WARN: option --virt-name $VIRT_PREFIX has ${#VIRT_PREFIX} characters which might be too long, consider making it shorter in case of errors" >&2
fi
if [[ ! -z $VIRT_NAME ]] && is_vface_name_allocated $VIRT_NAME; then
echo "WARN: interface $VIRT_NAME aleady exists, this will cause an error"
fi fi
} }
@ -1674,14 +1671,8 @@ prepare_wifi_interface() {
echo "${VWIFI_IFACE} created" echo "${VWIFI_IFACE} created"
else else
VWIFI_IFACE= VWIFI_IFACE=
if [[ ! -z ${VIRT_NAME} ]] && [[ ${#VIRT_NAME} -gt 15 ]]; then
die "Failed creating virtual WiFi interface. This is likely because you have set a long name for your virtual interface using --virt-name, try making it shorter'"
elif [[ -z ${VIRT_NAME} ]] && [[ ${#WIFI_IFACE} -gt 13 ]]; then
die "Failed creating virtual WiFi interface. This is likely because your interface name is too long. Try using '--virt-name <shorter interface name>'"
else
die "Failed creating virtual WiFi interface. Maybe your WiFi adapter does not fully support virtual interfaces. Try again with '--no-virt'" die "Failed creating virtual WiFi interface. Maybe your WiFi adapter does not fully support virtual interfaces. Try again with '--no-virt'"
fi fi
fi
AP_IFACE=${VWIFI_IFACE} AP_IFACE=${VWIFI_IFACE}
else # no virtual wifi interface, use wifi device interface itself else # no virtual wifi interface, use wifi device interface itself