I want to set up multiple virtual machines to run webserver, postfix, etc.
I have a few public IP-Adresses from my ISP. My host system is running Centos 7 and my virtual machines are running Debian Wheezy. Since my hoster restrict access to the switch based on MAC Address, I cannot use a "full" bridge.
Instead I configured a routed bridge (see http://wiki.hetzner.de/index.php/Proxmox_VE)
I have successfully set up both machines, but the vm cannot connect to the internet if my firewall on my host machine is active. If my firewall is active I can ping machines on the internet from my vm, but nothing else.
How can I configure my firewall under Centos 7 to give the VMs on br0 acces to internet?
Any help is appreciated. Thank you very much.
Network Config Host Machine
Host-Machine: /etc/sysconfig/network-scripts/ifcfg-enp2s0
BOOTPROTO=none
DEVICE=enp2s0
ONBOOT=yes
IPADDR=A.A.A.42
NETMASK=255.255.255.255
SCOPE="peer A.A.A.1"
Host-Machine: /etc/sysconfig/network-scripts/route-enp2s0
ADDRESS0=0.0.0.0
NETMASK0=0.0.0.0
GATEWAY0=A.A.A.1
Host-Machine: /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE="Bridge"
ONBOOT=yes
BOOTPROTO=none
IPADDR=A.A.A.42
NETMASK=255.255.255.255
STP=off
DELAY=0
Host Machine: /etc/sysconfig/network-scripts/route-br0
ADDRESS0=B.B.B.160
NETMASK0=255.255.255.255
Network Config Virtual machine
Virtual machine: /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address B.B.B.160
netmask 255.255.255.255
pointopoint A.A.A.42
gateway A.A.A.42
Firewall settings Host machine
firewall-cmd --list-all
public (default, active)
interfaces: br0 enp2s0
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
Thank you very much in advance.
To accomplish, you have two options.
Option1:(from a security perspective this method is recommended)
Disable netfilter on the configured bridge
# vi /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
Check the values before/after.
# sysctl -p /etc/sysctl.conf
Option2:
Add direct firewall rule
firewall-cmd --direct --add-chain ipv4 filter FORWARD 0 -m physdev --physdev-is-bridged -j ACCEPT
On CentOS 8 (and probably CentOS 7) with firewalld, there's a much easier way to get all routed bridged KVM virtual machines full unrestricted internet access without dealing with firewall rules.
By default, all interfaces are bound to the public firewall zone.
But there are multiple zones, ie firewall-cmd --list-all-zones of which one is called trusted, which is an unfiltered firewall zone that accepts all packets by default.
So you can just bind the bridge interface to that zone.
firewall-cmd --remove-interface br0 --zone=public --permanent
firewall-cmd --add-interface br0 --zone=trusted --permanent
firewall-cmd --reload
Hope this helps.
Related
I created a vm (vm-devstack-01) using Vagrant and Virtualbox in which I installed Devstack. The vm has an enp0s3 interface in NAT mode and an enp0s8 interface in bridge mode. The real network I use in my house is 192.168.88.0/24. This network uses DHCP addressing.
vm-devstack-01:
I set FLOATING_RANGE from local.conf to 192.168.88.224/27.
My local.conf:
[[local|localrc]]
ADMIN_PASSWORD=admin
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
HOST_IP=192.168.88.43
FLAT_INTERFACE=enp0s8
FLOATING_RANGE=192.168.88.224/27
FIXED_RANGE=10.11.12.0/24
FIXED_NETWORK_SIZE=256
Later I created a debian VM (vm-debian-01) on openstack which received floating ip 192.168.88.230.
Also, the security group releasing the ping was created:
Ingress IPv4 ICMP Any 0.0.0.0/0
With this configuration it was possible to ping vm-devstack-01 to vm-debian-01 created inside openstack.
But I can't ping from the real machine (my notebook - IP 192.168.88.28) to vm-debian-01. What am I doing wrong ?
You need MASQUERADE definitions on your Openstack host machine.
That is, network translation for packets to-from your VM.
At the same time, you need routing to your Openstack host from all other networks that you want to reach VM's.
Masquerade rules
Routing
Proper Security Group settings in Openstack
I used vagrant to install KVM followed this guide:
https://www.cyberciti.biz/faq/installing-kvm-on-ubuntu-16-04-lts-server/
Here changed the bridged networking:
Step 3: Configure bridged networking
$ sudo cp /etc/network/interfaces /etc/network/interfaces.bakup-1-july-2016
$ sudo vi /etc/network/interfaces
auto br1
iface br0 inet static
address 10.18.44.26
netmask 255.255.255.192
broadcast 10.18.44.63
dns-nameservers 10.0.80.11 10.0.80.12
# set static route for LAN
post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.18.44.1
post-up route add -net 161.26.0.0 netmask 255.255.0.0 gw 10.18.44.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
# br1 setup with static wan IPv4 with ISP router as a default gateway
auto br1
iface br1 inet static
address 208.43.222.51
netmask 255.255.255.248
broadcast 208.43.222.55
gateway 208.43.222.49
bridge_ports eth1
bridge_stp off
bridge_fd 0
bridge_maxwait 0
$ sudo systemctl restart networking
When I restart vagrant, it always stop here:
$ vagrant up
==> default: Attempting graceful shutdown of VM...
default: Guest communication could not be established! This is usually because
default: SSH is not running, the authentication information was changed,
default: or some other networking issue. Vagrant will force halt, if
default: capable.
==> default: Forcing shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
How can fix it?
If you're using vagrant, you dont need to make those modification, you can just change in your Vagrantfile the network configuration (see Public Networks) and make the change
Vagrant.configure("2") do |config|
...
config.vm.network "public_network"
...
end
vagrant will take care to update the right configuration file
I am new to openstack and I followed the installation guide of icehouse for ubuntu 12.04/14.04
I chose 3 node architecture. Controller, Nova, Neutron.
The 3 nodes are installed in VM's. I used nested KVM. Inside VM's kvm is supported so nova will use virt_type=kvm. In controller I created 2 nics. eth0 is a NAT interface with ip 203.0.113.94 and eth1 a host only interface with ip 10.0.0.11.
In nova there are 3 nics. eth0 NAT - 203.0.113.23, eth1 host only 10.0.0.31 and eth2 another host only 10.0.1.31
In neutron 3 nics. eth0 NAT 203.0.113.234, eth1 host only 10.0.0.21 and eth2 another hosty only 10.0.1.21 (during installation guide in neutron node i created a br-ex (and a port to eth0) which took the settings of eth0 and eth0 settings are:
auto eth0 iface eth0 inet manual up ifconfig $IFACE 0.0.0.0 up
up ip link set $IFACE promisc on
down ip link set $IFACE promisc off
down ifconfig $IFACE down)
Everything seemed fine. I can create networks, routers etc, boot instances but I have this error.
When I launch an instance it takes a fixed ip but when I log in into instance (cirros) can't ping anything. ifconfig with no ip.
I noticed that in demo-net (tenant network) properties under subnet in the ports field it has 3 ports. 172.16.1.1 network:router_interface active 172.16.1.3 network:dhcp active 172.16.1.6 compute:nova down
I searched for solutions over the net but couldn't find anything!
Any help?
Ask me if you want specific logs because I don't know which ones to post!
Thanks anyway!
Looks like you are using Fixed IP to ping..If so please assign floating IP to your instance, and then try to ping..
If you have already assigned floating IP and you are pinging using that IP..please upload log of your instance
I am facing issue with accessing Open stack VM's on LAN.
I have setup single machine(192.168.2.15) opensatck using devstack, so
all VM's are running inside this machine
My machine(192.168.2.15) has one network card(eth0) and
I have nova networking, have not installed neutron.
I have assigned static IP on eth0 of all the LAN machine( such as 192.168.2.15 and 192.168.2.16) in /etc/network/interfaces file.
System information of the Openstack Machine is as below:
Memory usage: 19% IP address for virbr0: 192.168.122.1
Swap usage: 0% IP address for br100: 10.0.0.1
Below works fine
I can access internet from VM1(10.0.0.2 which is auto assigned IP).
I can ping LAN machine(192.168.2.16) from VM1.
Openstack machine(192.168.2.15) can ping VM1(10.0.0.2).
VM1(10.0.0.2) can ping VM2(10.0.0.3).
But LAN machine 192.168.2.16 is not able to ping VM1(10.0.0.2)
So please suggest how can it be achieved ? And Please consider me as very new to Openstack and networking.
Thanks !!!
You need to assign a floating IP to the VMs you create if you want a host from outside the openstack network to connect to it. The internal IPs are only accessible from inside the openstack network.
See how to assign a floating IP to a VM here: http://docs.openstack.org/user-guide/content/floating_ip_allocate.html
To access the VM's floating IP from another host (that is not the devstack host) you should make sure that the devstack host is configured to forward packets. You can do this with:
sudo bash
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
See more details here:
http://barakme.tumblr.com/post/70895539608/openstack-in-a-box-setting-up-devstack-havana-on-your
Adding a route to client machine to openstack VM, helped me.
I am trying to set up a traffic control server between the network and the firewall-router.
The server has two network devices:
Firewall <--> Server <---> NETWORK
It is running CentOS 6.4 x64 and I would like to use Etherape.
My idea is to have eth0 connected directly to our router and eth1 to our network.
eth1 would have two virtual interfaces, one with an IP to ssh the server and the other just forwarding with IPTables to eth0 with no IP. Of course, eth0 would not have any IP (we don't want to change the Gateway).
Any suggestion or better way to do this?
Thank you very much!!
Ok, finally it was quite easy. Install brctl and etherape, then:
brctl addbr br0
brctl stp br0 off
brctl addif br0 eth0
brctl addif br0 eth1
echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig eth0 up
ifconfig eth1 up
ifconfig br0 up
service network restart
ifconfig br0 XX.YY.ZZ.AA
That is a temporal configuration. If you reboot you have to re-do it. Here is a way to make it persistent:
http://www.tldp.org/HOWTO/Ethernet-Bridge-netfilter-HOWTO.html#toc3.3
Finally, (installing if you are in a Windows Box, Xming and Putty and) connecting as root to XX.YY.ZZ.AA with X11 redirection, execute etherape and you will have you remote traffic control.
To make it easier, I will recommend to add the filter:
ip and not ((src net XX.YY.ZZ.AA) or dst net XX.YY.ZZ.AA)
To avoid the X11 traffic between the server and your box.