You are not logged in.

#1 2017-07-01 15:48:15

SeoDisparate
Member
Registered: 2015-09-12
Posts: 10

[SOLVED] sshd socks through ad-hoc wifi network

I get terrible wifi signal from my room, but my desktop is wired directly to the router, so I figure why not adhoc wifi to my desktop which is much closer than my router?

I am able to setup a wifi adhoc network with the following script for both laptop and desktop:

rfkill unblock wifi
exitIfFail "rfkill unblock wifi"
iw wlp3s0 set type ibss
exitIfFail "iw wlp3s0 set type ibss"
ip link set wlp3s0 up
exitIfFail "ip link set wlp3s0 up"
iw wlp3s0 ibss join SSLN 2432
exitIfFail "iw wlp3s0 ibss join SSLN 2432"

echo "Wifi Ad-Hoc is partially setup, now setting local address stuff..."
sleep 1s

ip addr add 192.168.2.${LAST_BYTE_IP}/24 broadcast 192.168.2.255 dev wlp3s0
exitIfFail "ip addr add 192.168.2.${LAST_BYTE_IP}/24 broadcast 192.168.2.255 dev wlp3s0"
ip route add default via 192.168.2.1
exitIfFail "ip route add default via 192.168.2.1"

echo "Done"

For some reason,

 ssh -D <port> <desktop_host> 

works at first, but when I try to use the socks ssh proxy, connection fails and the following is logged:

sshd[5285]: error: connect_to duckduckgo.com: unknown host (Name or service not known) 

I suspect it's because I'm ssh-ing to the desktop on an interface that isn't connected to the internet (wlp3s0/wireless instead of enp0s25/wired), but I'm not sure how to fix.
Any suggestions?

EDIT: Just noticed the host desktop computer cannot access the internet anymore when the adhoc network is up. I think it tries to connect through the ad-hoc network rather than the existing connection on a separate interface. Perhaps fixing this will fix the problem?

EDIT2: I fixed the problem. Turns out

ip route add default via 192.168.2.1

makes the adhoc network's interface seem like it's connected to the internet? The final adhoc script is as follows:

rfkill unblock wifi
exitIfFail "rfkill unblock wifi"
iw wlp3s0 set type ibss
exitIfFail "iw wlp3s0 set type ibss"
ip link set wlp3s0 up
exitIfFail "ip link set wlp3s0 up"
iw wlp3s0 ibss join SSLN 2432
exitIfFail "iw wlp3s0 ibss join SSLN 2432"

echo "Wifi Ad-Hoc is partially setup, now setting local address stuff..."
sleep 1s

ip addr add 192.168.2.${LAST_BYTE_IP}/24 broadcast 192.168.2.255 dev wlp3s0
exitIfFail "ip addr add 192.168.2.${LAST_BYTE_IP}/24 broadcast 192.168.2.255 dev wlp3s0"
#ip route add default via 192.168.2.1
#exitIfFail "ip route add default via 192.168.2.1"

echo "Done"

Note "exitIfFail" is a bash function checking if the previous command resulted successfully, and exits if not.

Last edited by SeoDisparate (2017-07-02 03:45:58)

Offline

Board footer

Powered by FluxBB