LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 09-15-2019, 02:40 PM   #1
gunnarniels
LQ Newbie
 
Registered: Sep 2019
Posts: 2

Rep: Reputation: Disabled
Trying to simulate Centos 7 box as a router, running into some problems


A bit about my setup, I'm primarily trying to understand all of this using nmcli since that seems to be where RHEL 8 is heading. I'll try to bold my questions.

My LAN: 192.168.1.0/24, gateway 192.168.1.254 out to internet.

Host machine: CentOS 7, 2 nics:
lan-eth (enp8s1) - static ip of 192.168.1.2, gateway: 192.168.1.254
Then I set up a bridge so I can put a VM on my main LAN with a 2nd nic (wnp5s0):

Code:
nmcli con create type bridge ifname external-bridge con-name external-bridge
nmcli con add type bridge-slave ifname enp5s0 master external-bridge
I assigned a static ip to the bridge with 192.168.1.3, rebooted.

---

I'm experimenting with various gateway/firewall software like pfsense, ipfire, and decided I wanted to understand it on a low level to approximate a router/gateway just with vanilla CentOS. So the plan is:

* One VM with 2 nics approximating a router, call it (gate):
NIC 1: DHCP that's plugged into the external-bridge, as if it's plugged directly into my main LAN. MY main router would assign an IP with DHCP, simulates an IP assigned from an ISP.
NIC 2: NIC plugged into a *2nd* bridge (net2) on the host. This bridge acts as a 2nd subnet (192.168.2.0/24), and the IP of this nic would be a static 192.168.2.1. It would act as a gateway for this 2nd net, running DHCP on NIC 2 for the 2nd net.

* N VMs that simulate hosts plugged into the net2 bridge. They're pretty simple hosts, one nic, gets their net2 address from (gate). They can talk to all the other hosts on net2, or (key part that's broken) talk to the internet through gate, which forwards to my main LAN gateway 192.168.1.254, which forwards out to the net.

To accomplish this, I created the net2 bridge:
Code:
nmcli con create type bridge ifname net2 con-name net2
This created a bridge that nmcli seems to continue to think it's perpetually in a "connecting" state. It's entirely valid for this bridge to not have its own IP, correct? I just want it to act as a simple switch between the net2 machines.

At first I thought I would need to manually add TAP devices that are slaves to the respective bridges, and the VMs would use these TAP devices. But it appears that virt-manager actually creates a new TAP device (vnetN) when you select a bridge for a VM's NIC.
Do I need to (is it possible?) to manually create TAP devices attached to bridges ahead of time for VMs?

I created the gate VM with one NIC in the external-bridge, selected when I added the NIC. Added another NIC and selected the net2 bridge, which is noted as empty. When this VM got launched, I see vnet0 assigned to the external bridge, but I do NOT see an expected vnet1 associated with the net2 bridge. Did I need to manually create this for some reason? I assigned a static address of 192.168.2.1 to the 2nd nic, with a gateway of 192.168.1.254.

Seeing I'm missing this tap device, I created another vm attached to net2 bridge as if it were a host to be routed by the gate. Interestingly, a tap device showed up associated with net2 bridge. I tried to ping 192.168.2.1 (the gate machine), but it would not ping. I rebooted gate, and interestingly, a vnet device showed up now that's in the net2 bridge.

So now I have my gate device acting as the router between 192.168.1.0/24 and 192.168.2.0/24, and I have a net2 host at 192.168.2.2. I can ping the gate from the net2 host but I cannot ping any machines on my main LAN, which I would expect to be able to do because the gate would forward packets to the main LAN's gateway.

I enabled ipv4 forwarding on both my bare metal host, and on the gate vm. This is necessary, correct?

Overall, I just can't seem to get network traffic out of the net2 host. I'm not sure what I might have done wrong between the bare metal host, its bridges, and the gate vm. Any tips with this?
 
Old 09-15-2019, 05:50 PM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,320

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
I don't actually have any personal experience with this, but
Is nmcli the correct tool?

https://netplan.io/
Network Manager plays a part, but I think you may need to look at the underlying netplan configuration first.
 
Old 09-15-2019, 06:06 PM   #3
gunnarniels
LQ Newbie
 
Registered: Sep 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Firerat View Post
I don't actually have any personal experience with this, but
Is nmcli the correct tool?

https://netplan.io/
Network Manager plays a part, but I think you may need to look at the underlying netplan configuration first.
I know libvirt will set up networks for you, but since I'm trying to learn the underlying interface networking of it, I was hoping I could set things up myself. I'm particularly interested in being able to set up my own bridges and wire vms into them as I see fit.

Correct me if I'm wrong, but nmcli and NetworkManager should be able to do all of what `ip` can do? If that's not correct please let me know. A lot of this spawned from me experimenting with RHEL 8 and their docs, and they seem to be firmly recommending nmcli and NetworkManager. I was surprised to find brctl is simply gone (I've since learned it's considered to be deprecated).

I see a lot of mixed recommendations between nmcli and ip...is there a recommendation when to use one over the other?
 
Old 09-15-2019, 06:57 PM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,320

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
Sorry yeah, that netplan might be a red herring, I may have mixed up cent and ubuntu

redhat introduction-to-linux-interfaces-for-virtual-networking

all with IP

nmcli might have shorthand for those IP examples

if nmcli is not working, try the ip , confirm that works and revisit nm
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] CentOS 7 - Problems with firewalld/iptables on CentOS 7 Router -Can't connect to MariaDB between private networks (Virtual Box) arkfantasy CentOS 4 01-09-2017 01:56 PM
Is possible to simulate Load balancing algorithms using NS-2?for example i am trying to simulate Least Connection algorithm. mariio Linux - Networking 3 05-05-2016 08:06 AM
LXer: How to turn your CentOS box into an OSPF router using Quagga LXer Syndicated Linux News 0 09-26-2014 07:51 PM
How does one convert a Fedora Core 4 box into CentOs 5 box in a live environment? 242 Linux - Newbie 3 01-17-2011 10:25 PM
Setting up CentOS 5.3 Linux Box into Router tdog89 Linux - Networking 9 05-05-2009 08:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 06:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration