Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script reconfiguring local interface and cutting off local ssh #31

Open
varoudis opened this issue Jan 12, 2022 · 4 comments
Open

script reconfiguring local interface and cutting off local ssh #31

varoudis opened this issue Jan 12, 2022 · 4 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@varoudis
Copy link

Hi,

I cant find a way to run the script without killing my own link to the system.

On the 'router':
eth0 is on 192.168.166.100 (Im connecting to it from 192.168.166.110 via ssh)
wlan0 is the link to the internet (no firewalls, no VPNs etc.. simple wifi).

I tried both:
sudo lnxrouter -i eth0 -o wlan0
and:
sudo lnxrouter -i eth0 -o wlan0 -g 192.168.166.100

Both killed my link to the 'router' from eth0.
Am I missing something?
Thanks

@garywill
Copy link
Owner

I guess this is the network you're trying to make:

Internet ---[ wlan0 - router - eth0 ]----- computers

Am I getting it right?

The current script -i eth0 will reset eth0.
To solve this, we need to implement an option to not reset in future version.

BTW, currently can you reconnect to router via ssh after running the command and it resetting?

Before the fix is implemented, there's workaround.
Try comment out these:

linux-router/lnxrouter

Lines 2008 to 2032 in f6995bc

# initialize subnet interface
# take subnet interface down first
ip link set down dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} down"
# flush old IPs of subnet interface
ip addr flush ${SUBNET_IFACE} || die "Failed flush ${SUBNET_IFACE} IP"
dealwith_mac # setting MAC should be after setting NM unmanaged
[[ $WIFI_IFACE ]] && check_rfkill_unblock_wifi
# bring subnet interface up
ip link set up dev ${SUBNET_IFACE} || die "Failed bringing ${SUBNET_IFACE} up"
# hostapd , haveged
[[ $WIFI_IFACE ]] && run_wifi_ap_processes
# add ipv4 address to subnet interface
ip -4 addr add ${GATEWAY}/24 broadcast ${GATEWAY%.*}.255 dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} IPv4 address"
set_ipv6_bits
# add ipv6 address to subnet interface
if [[ $IPV6 -eq 1 ]] ; then
ip -6 addr add ${GATEWAY6}/64 dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} IPv6 address"
fi

ip link set down dev ${SUBNET_IFACE}

ip addr flush ${SUBNET_IFACE}

restore_interface_status

Then run

sudo lnxrouter -i eth0  -g 192.168.166.100

(Notice this is a dirty workaround for your current use case only, not a true fix)
I haven't tested.

@varoudis
Copy link
Author

hi and thanks for the quick response!

This is my actual setup.
Internet ---[ wlan0 - router (PiZero2) - usb0 ]----- just one computer - ethernet over USB
I have the feeling that the reset if killing the usb0 (gadget mode) and is not coming back at all...

Ill check you temp fix.
Best
Tasos

@garywill garywill added bug Something isn't working enhancement New feature or request labels Jan 13, 2022
@varoudis
Copy link
Author

varoudis commented Jan 19, 2022

@garywill

This is what I got:

sudo ./lnxrouter -i usb0 -g 192.168.166.100                                                                                          1 ⨯
linux-router 0.6.6 (https://github.com/garywill/linux-router)
Released under LGPL, with no warranty. Use on your own risk.

PID: 1075
Target interface is usb0 (3a:ea:66:54:bc:a2)
RTNETLINK answers: File exists
Error occured

ERROR: Failed setting usb0 IPv4 address



Doing cleanup..
Undoing iptables changes ..
Exiting: This is the only running instance
Cleaning up done

and:

sudo ./lnxrouter -i usb0 -o wlan0 -g 192.168.166.100
[sudo] password for kali:
linux-router 0.6.6 (https://github.com/garywill/linux-router)
Released under LGPL, with no warranty. Use on your own risk.

PID: 991
Target interface is usb0 (3a:ea:66:54:bc:a2)
RTNETLINK answers: File exists
Error occured

ERROR: Failed setting usb0 IPv4 address



Doing cleanup..
Undoing iptables changes ..
Exiting: This is the only running instance
Cleaning up done

With your edits above.
Thanks

@garywill
Copy link
Owner

Sorry for inconvinence. Try branch https://github.com/garywill/linux-router/tree/workaround-31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants