How can two subnets be connected?
Vbox1 subnet ifconfig:
eth0 Link encap:Ethernet HWaddr 08:00:27:f1:68:9e inet addr:192.168.1.65 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fef1:689e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:207703 errors:0 dropped:0 overruns:0 frame:0 TX packets:41701 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:45480669 (45.4 MB) TX bytes:4855362 (4.8 MB) eth1 Link encap:Ethernet HWaddr 08:00:27:79:02:34 inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe79:234/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:913 errors:0 dropped:0 overruns:0 frame:0 TX packets:1335 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:129887 (129.8 KB) TX bytes:150700 (150.7 KB) 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:15106 errors:0 dropped:0 overruns:0 frame:0 TX packets:15106 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:949613 (949.6 KB) TX bytes:949613 (949.6 KB)
And p4 (because I do not have access to that machine from here, I give a manual-typed summary):
etho : only inet6 addr lo : inet addr : 127.0.0.1 Mask : 255.0.0.0 venet0 : only inet6 addr vmbr0 : inet addr : 192.168.0.70 BCast : 192.168.0.255 Mask : 255.255.255.0
Two subnets were connected successful. After switching of ISP I can not access the p4 subnet anymore. So something has changed, but I expect it should be a minor problem, because before using subnets it was working successful.
I have read Virtual machine in two subnets, but the suggestion is to use VLAN. But according to Best way to segment traffic, VLAN or subnet? VLAN works on network layer 2, and subnet on network layer 3. And layer 3, subnets, should be used.
So I should have a gateway between these subnets.
According to Ubuntu KB – Network Config I added to vbox1:
sudo route add default gw 10.10.14.81 eth1
But it generates:
SIOCADDRT: Network is unreachable
Searching returns Ubuntu tunnel or gateway a difference between a host address and a network address.
I am stuck now.
Move vbox1 to a different subnet: Change its IP address on eth0 from 192.168.1.65 to 192.168.0.65 (or some other free IP address in the subnet 192.168.0.0/24). Then, vbox1 knows via which interface p4 (192.168.0.70) is accessible (–> via eth0). vbox1 automatically adjusts its routing table then.
Now you should be able to access p4 from vbox1. If you want to access p4 from any additional client in 192.168.1.0/24, you need to configure vbox1 as a router (i.e. a device that can forward packets arriving on eth1 [192.168.1.0/24] to eth0 [192.168.0.0/24] (and vice-versa). That’s what’s meant by “connecting two networks”).
How to do that depends on the distribution you are using. Basically, you need to write “1” into the device file
echo 1 > /proc/sys/net/ipv4/ip_forward
This, however is only valid during the current boot cycle. The setting is gone after a reboot.
If you want to do that permanently, you have to put this line into some startup script.
If you are using Ubuntu, you can also put this into /etc/sysctl.conf (I’m not sure about other distros).
Uncomment the line
If you want to have this in effect immediately, you can also issue
sudo sysctl -w net.ipv4.ip_forward=1 instead of the ´echo´ mentioned above.
Pls. see also this link on askubuntu.com.