Raspberry Pi network shenanigans (Linux)


  • Winner of the 2016 Presidential Election

    Okay, So let me preface this:
    I tried setting up my Raspberry Pi network stuff before. It took me 3 formats and buying a new router to even get it working on just my network. I gave up at that point, kinda forcing my Pi to stay at home.
    Now I feel like changing that.

    Long Preface version (feel free to skip)
    My old router was broken so it could not assign static IPs. That sucked for me, since I kinda wanted my Pi to be on a static IP so I wouldn't have to look its IP adress up everytime. There are various tutorial on the internet that describe the set up and either they all suck, my Pi is special or I am just too dumb to get this working. After a lot of trial, error and failure, I figured it was time for a real router so the thing had a static IP at least at home. about a year later (now), I would like to take the thing with me to university to play around with it some more. Thats my standpoint right now.
    I am not a sys-admin. I can manage my way around a Linux-system via console and am smart enough to only rarely run sudo rm -rf / (and whatever new flags there are now) accidentally.

    What do I want?
    I want to connect to various networks depending on various circumstances.
    I think pretty much all of it sounds like something very basic but as I said before, my attempts failed me so far.

    Okay, but what do I actually want
    I want the pi to try to connect to a network depending on the following circumstances (in that order):
    1.) If there is an ethernet cable plugged in:
    1.a) And it connects to a router -> get adress via DHCP and connect me to the internet
    1.b) and it connects to a computer -> set a static adress that the computer can use to access it.
    2.) If the USB-wireless dongle I own is plugged in:
    2.a) If possible -> set a static IP and still somehow manage to connect to the internet, please?
    2.b) if that is not possible, try to get an adress via DHCP, I guess. (Which I would set static via my router)
    Also, obviously connect to a known network once one is found.
    3.) If I have a cable and the wireless dongle plugged in, I want to be able to use the cable connection to make use of the wireless dongle to search for wireless networks and add them to my list of known networks (including login data)

    1. If none of the two options above are possible, I guess it should do nothing. Until I plug either a wireless dongle or a cable. Then I'd really love 1 or 2 to start taking effect.

    Is this behaviour possible?
    If so, is it somewhat easy to setup?

    Do I have any idea why things didn't work out last time I tried?
    No

    What kind of Pi am I talking about
    I own a Raspbery Pi B and a Raspberry Pi 2
    They both run Raspbian and are pretty standard.
    I have no idea what that wireless dongle is. I assume it's some kind of standard thing as well.

    Feel free to ridicule me for asking for something that seems so easy. I am just scarred from my earlier attempts and figured asking you guys I can at least interact with.
    Also feel free to ask for clarification.

    Filed Under: no, I won't run format the system for this


  • Winner of the 2016 Presidential Election

    Hmm, I'm not sure why you had issues. As long as your assigned IP wasn't in conflict...

    Yes, that should be reasonably easy to do. The most difficult part (requiring some scripting, probably) would be the wireless+wifi connection.

    The other things can be done just by messing around with the interface file, which... I don't remember off the top of my head...



  • You've heard of that thing, called NetworkManager? It also works on a RPi. On anything modern Linux enough. Takes care of most things for you (unless you happen to have a multi-NIC monster doing its own BGP and shit).

    @Kuro said:

    2.) If the USB-wireless dongle I own is plugged in:
    2.a) If possible -> set a static IP and still somehow manage to connect to the internet, please?
    2.b) if that is not possible, try to get an adress via DHCP, I guess. (Which I would set static via my router)
    Also, obviously connect to a known network once one is found.
    3.) If I have a cable and the wireless dongle plugged in, I want to be able to use the cable connection to make use of the wireless dongle to search for wireless networks and add them to my list of known networks (including login data)

    This smells me of deeply rooted ignorance as to how wireless networks even work.
    Why would you need an Ethernet connection to discover WLANs?


  • Winner of the 2016 Presidential Election

    @wft said:

    This smells me of deeply rooted ignorance as to how wireless networks even work.Why would you need an Ethernet connection to discover WLANs?

    Bad wording.

    He wants to use only the ethernet connection so the wifi connection isn't in use and the dongle can scan


  • sockdevs

    my sugestion?

    make the rpi's just statically take 192.168.xx.253 and 192.168.xx.254

    most consumer routers hand out dynamic IP addresses in the range 192.168.xx.100 to 192.168.xx.150 so picking addresses <50 or >250 inthe last octet are very unlikely to get conflicts.


  • Winner of the 2016 Presidential Election

    @wft said:

    You've heard of that thing, called NetworkManager?

    You mean some kind of GUI? I tried that... it was the first thing that failed. Hence I turned to manipulating files by hand...

    Edit: Actually, wait, thats a program that was not preinstalled. I honestly don't remember if I tried that exact one back then... give me a few minutes, I guess

    @wft said:

    This smells me of deeply rooted ignorance as to how wireless networks even work.Why would you need an Ethernet connection to discover WLANs?

    Probably ignorant. But also just inability to explain what I mean. I really just want to... aaaand @sloosecannon :hanzo:'d me

    Filed Under: Sorry



  • @sloosecannon said:

    The other things can be done just by messing around with the interface file, which... I don't remember off the top of my head...

    I guess /etc/networks/interfaces is a royal pain when it comes to wireless networks. There is that whole wireless layer, with authentication and shit, you need to configure it too, before an actual data packet can go in or out.

    Without some kind of management software, it's hard. I don't dare to muck with wpa_supplicant myself. In NetworkManager, thankfully, it all just works. And worked for years.


  • Winner of the 2016 Presidential Election

    @wft said:

    I guess /etc/networks/interfaces is a royal pain when it comes to wireless networks. There is that whole wireless layer, with authentication and shit, you need to configure it too, before an actual data packet can go in or out.

    Without some kind of management software, it's hard. I don't dare to muck with wpa_supplicant myself. In NetworkManager, thankfully, it all just works. And worked for years.

    Well yeah. I think since he wants the state changes to happen automagically though, he's gonna need some kind of CLI/scripting involved.

    I belive nmcli can do that though...


  • Winner of the 2016 Presidential Election

    If I recall correctly, I managed to set a static IP on my Pi last year by following a tutorial that I suspect was this one. But that only works for one network, I think, so I doubt it'll be much help. Unless you just keep two copies of that config file on hand and swap them out every time you take the Pi somewhere else.



  • @Kuro said:

    You mean some kind of GUI? I tried that... it was the first thing that failed. Hence I turned to manipulating files by hand...

    You know, there's a text UI for NetworkManager now. Install it and you're good to go.

    Find a place where DHCP works. Do an ifconfig -a to see how your Ethernet is named. Do dhclient -i eth0 (or other name your interface has). And there, you have internets. Install/reinstall packages at leisure.


  • Winner of the 2016 Presidential Election

    So, after re-reading the original post...

    @kuro - what exactly are you trying to do? Like what's the purpose of the project? I thought I got it on first read but it appears there's a fair bit of confusion as to your goal...



  • @Kuro said:

    1.b) and it connects to a computer -> set a static adress that the computer can use to access it.

    I think NM handles that too (with zeroconf; it assigns an address from 169.254.xx range, there's a standard for that). If you don't have a static IP for that interface and there's no DHCP, a self-assigned IP is given.


  • Winner of the 2016 Presidential Election

    @wft said:

    You know, there's a text UI for NetworkManager now. Install it and you're good to go.

    At it. Give me a few minutes. A Pi is not the fastest thing in the world :smiley:

    @sloosecannon said:

    what exactly are you trying to do? Like what's the purpose of the project? I thought I got it on first read but it appears there's a fair bit of confusion as to your goal...

    Really, all I wanted to do is plug in my Pi either at home (wireless or cable), or at university (wireless) or simply connect to it via direct ethernet cable. And I was hoping it would sort itself out. Which didn't happen back in the days. Hence the topic.


  • Winner of the 2016 Presidential Election

    And you want a static IP at home, but not anywhere else?


  • Winner of the 2016 Presidential Election

    Honestly, if I can get the static IP everywhere that'd be golden. But I figured since universities are usually full of statically assigned units, I'd settle for DHCP in that case.

    Filed Under: I turned down my requirements a lot during my last session of trying to make this work :D



  • @Kuro said:

    Really, all I wanted to do is plug in my Pi either at home (wireless or cable), or at university (wireless) or simply connect to it via direct ethernet cable. And I was hoping it would sort itself out. Which didn't happen back in the days. Hence the topic.

    You should have gone with that, and not elaborate.
    Now I see that all you want is basically what NetworkManager (and every PC, and every Mac) provides you out of the box.

    Also, Y U NO JUST USE DHCP?


  • Winner of the 2016 Presidential Election

    @Kuro said:

    simply connect to it via direct ethernet cable

    If you mean plug an Ethernet cable from your Pi directly into another computer, that won't work. You'll need at least a switch in between, and that's assuming you've got static IP's set.


  • Winner of the 2016 Presidential Election

    @wft said:

    You should have gone with that, and not elaborate.

    Noted!

    @wft said:

    Also, Y U NO JUST USE DHCP?

    The original idea was to take my laptop to university. Take the Pi to university. Plug both in -> know the IP. If I went the DHCP route, getting to know the IP to connect to the pi would require at least a monitor afaict.
    I mean, unless I completely misunderstand how these things work :smiley:

    Filed Under: Thats an option


  • Winner of the 2016 Presidential Election

    @Fox said:

    If you mean plug an Ethernet cable from your Pi directly into another computer, that won't work.

    It somewhat works if that computer is in a network already and shares the connection with the Pi. This method worked 2 times out of the 5 times I tried it :smiley:

    Filed Under Progress


    installing Network-manager-gnome now. Hoping thats the GUI? network-manager didn't come with one so far.


  • Winner of the 2016 Presidential Election

    @Kuro said:

    It somewhat works if that computer is in a network already and shares the connection with the Pi. This method worked 2 times out of the 5 times I tried it :smiley:

    Ahah, yes, that would also work. Maybe.



  • @Kuro said:

    The original idea was to take my laptop to university. Take the Pi to university. Plug both in -> know the IP. If I went the DHCP route, getting to know the IP to connect to the pi would require at least a monitor afaict.I mean, unless I completely misunderstand how these things work

    Put in a mdns service. Make it advertise itself. Read what mdns-sd is.



  • @Kuro said:

    installing Network-manager-gnome now. Hoping thats the GUI? network-manager didn't come with one so far.

    Doesn't need it for most things. You can even configure it statically. Install networkmanager-tui (nmtui) (maybe it's in the box already) if you go the headless route and ssh in.


  • Winner of the 2016 Presidential Election

    Well you should probably make sure that setting a static IP at the university will actually work - a lot of networks like that are very picky about what you're allowed to do...


  • Impossible Mission Players - A

    @sloosecannon said:

    make sure that setting a static IP at the university will actually work

    ^^ this. At my school any device unable to authenticate (using some Cisco blah blah security) gets shoved in its' own private closet and connectivity to the filtered/monitored proxy. Two devices right next to each other (physically) are barred from communicating, even if you actually know their IP addresses.


  • Winner of the 2016 Presidential Election

    @Tsaukpaetra said:

    @sloosecannon said:
    make sure that setting a static IP at the university will actually work

    ^^ this. At my school any device unable to authenticate (using some Cisco blah blah security) gets shoved in its' own private closet and connectivity to the filtered/monitored proxy. Two devices right next to each other (physically) are barred from communicating, even if you actually know their IP addresses.

    Fortunately we don't have Cisco auth crap, but something blocks any connectivity between devices on one of the (three) networks. The other two are more open but have really crappy speeds



  • @Fox said:

    If you mean plug an Ethernet cable from your Pi directly into another computer, that won't work. You'll need at least a switch in between

    The Pi's Ethernet port is auto MDI-X capable, so you don't actually need a switch. Just the patch cable should be fine (straight through or crossover, won't matter).

    Even if the Pi couldn't do this, every gigabit-capable Ethernet port ever made certainly can. Needing a switch has not been a thing for quite some time.


  • Winner of the 2016 Presidential Election

    This is just going to be some more trial and error, I hope. But I will definitly keep it in mind.

    @wft said:

    networkmanager

    Okay, so I installed it now and edited the interfaces file according to this stackexchange which makes me feel kind of dumb for simply following suggestions from the internet but at least I only commented the lines out instead of deleting them... So semi victory.

    Also a semi victory is that I now have a new icon for my wired connection. So that seems to work. It can't pick up the wireless connections via the dongle, though.
    Also trying to "edit" a connection tells me I am not authorized to control networking... thanks Linux? Might be because I am connected via vnc, though.

    Raspbian comes with a wpa_gui application. It is not detecting any wireless signals. It doesn't even find any adapter according to the white empty drop down menu. So I guess once I find out what stops me from using the wireless adapter, network-manager might be able to pick it up too.

    Filed Under: I am kinda enjoying this Linux treasure hunt right now. Being able to talk to you guys about it beats randomly using google by a lot

    Addendum: that Filed Under is supposed to mean Thank you to everybody helping me out here :D


  • Impossible Mission Players - A

    @Kuro said:

    wireless adapter

    You'll definitely need to make sure the drivers are available for it. Not all dongles work (INB4 :giggity:) properly or at all (in the case of some power hungry ones), and some require plugging into a USB hub before plugging into the Pi.


  • Winner of the 2016 Presidential Election

    Well... asking lsusb told me that I accidentally plugged in the bluetooth dongle I didn't know I had. So... I guess I can't fault my Pi here...

    Filed Under: Real life search for the WiFi-dongle commences

    Addendum: Found it #Yay


  • Impossible Mission Players - A

    @Kuro said:

    bluetooth dongle I didn't know I had

    Isn't it annoying that they don't physically mark them most of the time?
    I used a permanent marker to give them an identifiable color for this specific reason....



  • @Kuro said:

    If I went the DHCP route, getting to know the IP to connect to the pi would require at least a monitor afaict.

    If the university's network is properly configured then its DHCP and DNS servers will talk to each other. Provided your Pi has a hostname that doesn't clash with some other machine on the same subnet, then as soon as it gets an IP address assigned via DHCP, its hostname should get automatically added to the local DNS zone. So you should be able to connect to your Pi by name, without actually needing to know its IP address.


  • Impossible Mission Players - A

    @flabdablet said:

    university's network is properly configured

    :lollipop:


  • Winner of the 2016 Presidential Election

    The Wireless dongle is actually marked 802.11n. Which identifies it.
    The Bluetooth dongle just has a symbol on it that looks like the standard symbole for a wireless connection. Hence the confusion...


    Okay, so, I think I am almost somewhere. The drivers for the wireless adapter are installed and the network-manager picks up some signals.
    #but I can't click on them because I don't have the rights to edit the network...
    off to google I go....


    @flabdablet said:

    If the university's network is properly configured then its DHCP and DNS servers will talk to each other.

    my university calls itself a technical university... but I have serious doubts about the network being set up properly... I guess I'll have to find out tomorrow...

    Filed Under: I feel like a user should ALWAYS have access to his connections... why is that even a problem? ...


  • Impossible Mission Players - A

    @Kuro said:

    his connections

    Something something remote users shouldn't be able to affect network connectivity something something sledgehammer approach something.



  • @Kuro said:

    I can't click on them because I don't have the rights to edit the network

    Your desktop user account is probably not a member of the netdev group. Try doing
    sudo adduser kuro netdev
    and then log off and log on again.


  • Winner of the 2016 Presidential Election

    I assumed tightvnc would use the standard pi-user (since I never specified anything). It says "Pi's X Desktop" and according to groups pi belongs to the netdev-group.... So I dunno.

    I can "edit" the network if I start the tightvncserver as root... which gives me root's X Desktop. Dunno if the wireless settings are used for all accounts. I'll play around with that for a bit.

    Filed Under: But things look much nicer now. So thanks again to everybody


  • Discourse touched me in a no-no place

    @Fox said:

    If you mean plug an Ethernet cable from your Pi directly into another computer, that won't work. You'll need at least a switch in between, and that's assuming you've got static IP's set.

    Really? Why? You can do that with two PCs. I'm told you don't even need a crossover cable any more.


  • Discourse touched me in a no-no place

    @Kuro said:

    getting to know the IP to connect to the pi would require at least a monitor afaict.

    This seems like a nice excuse to write a program to drive a small 1x10 or something LCD.


  • Winner of the 2016 Presidential Election

    Well when I was trying it it didn't work. Maybe I was :doing_it_wrong:?


  • Winner of the 2016 Presidential Election

    Or, since it's just a pi...

    sudo su
    startx
    

    Then you should be able to do all the things


  • Winner of the 2016 Presidential Election

    Also, that would be really cool


  • Discourse touched me in a no-no place

    @sloosecannon said:

    Also, that would be really cool



  • @sloosecannon said:

    since it's just a pi...

    Well, yeah.

    But if you've got yourself a little Debian toy, picking up a few general Debian admin skills isn't a bad way to play with it.



  • My router takes the address 192.168.1.254 and won't let any device that isn't using DHCP send or recieve packets.


  • sockdevs

    Custom setup or came out of the box like that?

    because i was talking aobut the out of the box setups.

    once you tinker with the settings my assumptions no longer hold.



  • There is no way I can find to disable that behavior.


  • Winner of the 2016 Presidential Election

    DD-WRT?
    Is valid!



  • My router's current timestamp is 0000-00-29T01:53:31. There's also no setting to change that.


  • Winner of the 2016 Presidential Election

    Are there settings?



  • Yes. I can change the Wi-Fi password and there's a button here that drops all NAT connections.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.