Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a Raspberry Pi and have connected a USB Ethernet. I configured it to use my LAN and plugged it into my router, and can ping and SSH using the connection from other machines on my LAN.
Now that I know it is working, I am trying to do my end goal, and connect to it from another machine (either Ubuntu or Windows, and ideally ability to do with both) without a router. While I've read that a crossover cable is not required with most modern hardware, I am using one "just in case".
I've tried configuring the RPi network to both be on my LAN and on a different LAN and have met no success.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
You should be more specific.
Does the Pi have more than one IP address now?
Is it on different subnets? (like 192.168.20.10 and 192.168.300.10)?
What are the subnet masks used on the Pi and all other machine which you try to connect?
What are the IP's of the other machines on the "different" subnet?
Is there anything like a firewall between the Pi and the hosts you are using?
A crossover cable is not required. You say your had already communication.
Why do you use a USB<->eth. I though (almost) all Pi's have ethernet. Or does this model not?
jlinkels
Edit: did you connect all ethernet cables to a router, or to a switch? Note that routers like your ADSL modem often have 4 ethernet ports on the LAN end which act as a switch.
My home network is: Coax-----Modem-----Router1 (10.120.11.1)------Router2 (192.168.1.1)
The Pi's on-board Ethernet (eth0) has a static IP of 10.120.11.30 (I recognize my submask is likely not idea) and is connected to one of the 4 Ethernet ports of Router1. This part is not relevant.
If I set up the Pi's USB Ethernet (eth1) to use static IP of 192.168.1.222 and connect it to one of Router2's switches, I can connect to it from any machine connected to Router2's other switches.
Code:
michael@rpi:~ $ ip route
default via 10.120.11.1 dev eth0 metric 202
default via 192.168.1.1 dev eth1 metric 203
10.120.11.0/24 dev eth0 proto kernel scope link src 10.120.11.30 metric 202
192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.1.222 metric 203
michael@rpi:~ $ ifconfig -a
eth0 Link encap:Ethernet HWaddr b8:27:eb:77:55:11
inet addr:10.120.11.30 Bcast:10.120.11.255 Mask:255.255.255.0
inet6 addr: fe80::ab8c:e035:53c4:84c9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4483 errors:0 dropped:0 overruns:0 frame:0
TX packets:3956 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:760719 (742.8 KiB) TX bytes:678749 (662.8 KiB)
eth1 Link encap:Ethernet HWaddr 00:05:1b:b1:2c:45
inet addr:192.168.1.222 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::b867:2c83:b71b:3a6d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:704 errors:0 dropped:0 overruns:0 frame:0
TX packets:88 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:160548 (156.7 KiB) TX bytes:17502 (17.0 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
michael@rpi:~ $ cat /etc/dhcpcd.conf
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
require dhcp_server_identifier
slaac private
nohook lookup-hostname
interface eth0
static ip_address=10.120.11.30/24
static routers=10.120.11.1
static domain_name_servers=10.120.11.1
interface eth1
static ip_address=192.168.1.222/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
michael@rpi:
Code:
michael@michael-HP-EliteBook-2570p:~$ ping 192.168.1.222
PING 192.168.1.222 (192.168.1.222) 56(84) bytes of data.
64 bytes from 192.168.1.222: icmp_seq=1 ttl=64 time=1.02 ms
64 bytes from 192.168.1.222: icmp_seq=2 ttl=64 time=4.13 ms
^C
Now, I wish to disconnect the Pi's USB Ethernet from router2 and use an Ethernet cable to go directly between the Pi's USB Ethernet and some other machine's Ethernet connection. The IPs and masks can be whatever is desired.
Hello again jlinkels, I just made the RPi 192.168.2.222 and the other machine 192.168.2.220, and now it works perfect. I must have just typed something wrong.
Typically the network adapters are configured using DHCP so that when connected to a LAN the router automatically assigns an IP address.
However when connected directly together you have to assign a static IP address on each machine which means every time you switch networks you need to reconfigure everything.
A second option is using zeroconf link local addressing which hopefully Ubuntu and Windows still configures by default. When the DHCP client can not find a server it will default to assigning an address in the 169.254.0.0/16 subnet. So by just connecting the computers together they will "automatically" be networked. No reconfiguration necessary when plugged back into your router.
You should be able to configure zeroconf on the Pi by installing avahi.
I might have installed this in the past and forgot as both were already installed. Or maybe they come by default with Rasputian? Looks like https://packages.debian.org/jessie/libnss-mdns would have been required if not already installed.
Unless you setup dhcp server stuff you have to setup several parts manually.
1) the IP of the local interface
2) the gateway / routing (the ip of the remote interface)
3) DNS entries (/etc/resolv.conf in most cases for linux)
With various equivalent and probably more difficult to get to parts in other OSes. Where dhcp would probably work out of the box and handle all that for you.
If you have two networking interfaces and want to forward them you also need to change /proc/sys/net/ipv4/ip_forward to 1 (default is 0) to enable it. And without functional bridging you need to masquerade the connection in iptables / netfilter for the WAN facing interface.
As I look at my networking setup with the ISP to an asus rt-n12. Most everything else within hands reach etherneted to a micro 5 port switch attached to a banana pi m3, which does the wifi to the rt-n12. This gives me 4 usable ethernets within arms reach (1 of 5 is used by the BPi m3). Only 10/100 ports in this case, but the ISP is pretty slow. The rough equivalent of client_bridge with ddwrt that I used to do on an asus rt-n16 (which I gave to my dad).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.