Skip to content

script reconfiguring local interface and cutting off local ssh #31

Description

@varoudis

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

Activity

  1. garywill commented on Jan 13, 2022

    @garywill
    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.

  2. varoudis commented on Jan 13, 2022

    @varoudis
    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

  3. varoudis commented on Jan 19, 2022

    @varoudis
    Author

    @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

  4. garywill commented on Jan 20, 2022

    @garywill
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions