You are not logged in.

#1 2016-11-01 09:57:05

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

[Solved] Set up dual network

Hi!

I'm wondering how I can set up dual network.

I have two networks. One connects to the internet, and is assigned with an IP that can be accessed by the internet. The other network is internal.

I'm wondering how I can set up the system so that it uses the first network most of the time, except when accessing the internal network?

Thank you!

Last edited by Wen (2016-11-02 17:06:02)

Offline

#2 2016-11-01 10:39:35

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: [Solved] Set up dual network

Are you trying to set up a machine as a router? Then this article might help: https://wiki.archlinux.org/index.php/Internet_sharing

If you don't need that, then nothing special is required: you assign your LAN-facing NIC (network interface card) an IP address (either dynamically or statically), and the kernel will set up routes automatically. Just verify that the default route goes through the internet-facing NIC.

Example
You assign your LAN-facing NIC the IP address 192.168.1.10 with a network mask of 255.255.255.0 (short notation: /24).
The kernel will set up the routing rules such that all packets with a destination IP address in the 192.168.1.0/24 subnet (range: 192.168.1.0 (?) - 192.168.1.255) will be routed through that NIC.
If a packet's destination IP address is not in that subnet's range (and matches no other routing rules, if there are any), the default route is chosen, which should go through the internet-facing NIC.

EDIT

Here's an example routing table for my laptop:

default via 192.168.1.1 dev wlp3s0 proto dhcp src 192.168.1.121 metric 1024
172.16.110.0/24 dev qemu0 proto kernel scope link src 172.16.110.1 linkdown
192.168.1.0/24 dev wlp3s0 proto kernel scope link src 192.168.1.121
192.168.1.1 dev wlp3s0 proto dhcp scope link src 192.168.1.121 metric 1024

Here, I have been assigned 192.168.1.121/24 by the DHCP server on my WiFi NIC (wlp3s0), so packets with a destination IP address in 192.168.1.0/24 will be routed through wlp3s0.
Then, I have additionally assigned 172.16.110.1/24 to my VM-facing network bridge (qemu0), so packets with a destination IP address in 172.16.110.0/24 will be routed through qemu0.
Finally, there is a default route that tells packets that do not match any of those rules to go through wlp3s0 - which makes sense, because the internet is there smile

Last edited by ayekat (2016-11-01 10:45:23)


pkgshackscfgblag

Offline

#3 2016-11-02 12:44:04

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

Re: [Solved] Set up dual network

Thank you ayekat!

No, I do not intend to set up the machine as a router.

The machine has two network cards: wlp3s0 and eno1.

wlp3s0 is the wireless network adapter. I run wpa_supplicant to set up the network first, and then use dhclient to get an IP. This is network connects to the Internet.

eno1 is the wired network adapter. I run dhclient to get an IP. This connects to an internal network.

My plan is to set up an SSH server, so that I can ssh to this computer via wlp3s0, and then from there access the internal network through eno1.

I don't understand your routine table. Where do I edit it?

Thank you!

Offline

#4 2016-11-02 12:50:14

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: [Solved] Set up dual network

Just to clarify: the internal network (on eno1) is not the same as the one on wlp3s0?

Wen wrote:

Where do I edit it?

The routing table can be displayed with

ip route

If you use dhclient for both the wired and wireless network interface, it is possible that two default routes are set, in which case you will need to remove one of them.
See also https://wiki.archlinux.org/index.php/Ne … assignment


pkgshackscfgblag

Offline

#5 2016-11-02 13:46:53

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

Re: [Solved] Set up dual network

Thank you!

Good question! No, they are on different networks.

Offline

#6 2016-11-02 14:36:42

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

Re: [Solved] Set up dual network

Hi again,

Thanks to you, I have managed to get part of network setup:

default via 193.150.115.1 dev wlp3s0 
10.1.1.0/24 dev eno1 proto kernel scope link src 10.1.1.46 
193.150.115.0/22 dev wlp3s0 proto kernel scope link src 193.150.115.133

However, I'm not able to reach computers that are part of the internal network, for example, another computer with an IP address of 10.1.8.22.

I tried to add the following line:

# ip route add 10.1.8.0/24 dev eno1 proto kernel scope link src 10.1.1.46

However, this does not help. Could you help?

Offline

#7 2016-11-02 15:36:03

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: [Solved] Set up dual network

Wen wrote:
default via 193.150.115.1 dev wlp3s0 
10.1.1.0/24 dev eno1 proto kernel scope link src 10.1.1.46 
193.150.115.0/22 dev wlp3s0 proto kernel scope link src 193.150.115.133

However, I'm not able to reach computers that are part of the internal network, for example, another computer with an IP address of 10.1.8.22.

If your machine gets assigned 10.1.1.46/24, this means that it is part of the 10.1.1.0/24 network (range: 10.1.1.0 - 10.1.1.255).

The machine at 10.1.8.22 is outside that range and thus in another network. This leaves me wondering: are there multiple networks? Or how did the machine behind 10.1.8.22 obtain its IP address?

I tried to add the following line:

# ip route add 10.1.8.0/24 dev eno1 proto kernel scope link src 10.1.1.46

However, this does not help.

Perhaps your router's firewall prevents packets from crossing networks like that... honestly, I have never tried to set up a route where the source address is not part of that subnet, so I can't really tell you whether it's supposed to work or not. hmm


pkgshackscfgblag

Offline

#8 2016-11-02 16:36:05

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

Re: [Solved] Set up dual network

Thank you bud.

I do not know the configuration behind. I can access 10.1.8.22 when I set the default to be 10.1.1.1, strangely.

Offline

#9 2016-11-02 17:05:48

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

Re: [Solved] Set up dual network

Hey. I'm very happy to tell you that I have found a solution, which is so easy that I couldn't believe it:

ip route add 10.1.8.0/24 via 10.1.1.1 

Offline

#10 2016-11-02 17:06:24

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

Re: [Solved] Set up dual network

And thanks a lot for the journey!

Offline

#11 2016-11-03 08:03:59

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: [Solved] Set up dual network

Ah, now I get it - there are multiple networks, and the router (10.1.1.1) acts as the gateway (between 10.1.1.0/24 and 10.1.8.0/24), and if you send packets to the 10.1.8.0/24 network through that router, they follow the right path.
Nice to hear it worked out smile


pkgshackscfgblag

Offline

#12 2016-11-03 16:52:17

Wen
Member
From: Oslo, Norway
Registered: 2008-10-02
Posts: 40

Re: [Solved] Set up dual network

Yep! :-D

Offline

Board footer

Powered by FluxBB