Wednesday, 15 January 2014

Set Up Routing On A linux Machine

Routing on a Linux machine can be useful if you are running a home lab scenario. This will allow internet access to your virtual machines that may be on a different subnet to your main network connection.

This configuration has been tested in a home environment with a home router provided by Virgin Media

The Linux host I am using is CentOS 6.5
  1. Install the routing packages
    yum install quagga
  2. Edit the configuration file /etc/quagga/zebra.conf to look like as below
    hostname vhost
    password vhost
    enable password vhost

    interface lo
    multicast

    interface eth0
    multicast

    interface virbr0
    multicast

    interface virbr0-nic
    multicast log file /var/log/quagga/zebra.conf The interfaces highlighted in yellow are my virtual interfaces created by my virtualisation software, in this case it is virt-manager. These are the interfaces that bridge network connectivity between your virtual switch and your physical lab network
  3. Edit the configuration file /etc/quagga/ospfd.conf to look like as below

    hostname vhost
    password vhost
    enable password vhost


    router ospf
    router-id 192.168.0.25
    network 192.168.0.25/24 area 0
    network 192.168. 0100./24 area 0

    log file /var/log/quagga/ospfd.log

    The IP address in yellow needs to be changed to the IP of your host's network card that is connected to the physical network

    The network addresses in blue need to be set to the networks you want to route together. Note, these MUST be network addresses otherwise routing will not work
  4. Create the 2 log files and allow for write access to them

    sudo touch /var/log/quagga/zebra.conf sudo touch /var/log/quagga/ospfd.conf sudo chmod 777 /var/log/quagga/zebra.conf sudo chmod 777 /var/log/quagga/ospfd.conf 
    Note, the use of 777 should only be used in a testing environment, in a real live environment you may want to filter permissions a bit more as this allows all uses and processes to read, write and execute these files which can lead to a security hole.
  5. Edit the line in /etc/sysctl.conf to read net.ipv4.ip_forward = 1
  6. Edit the Linux firewall to be trusted on all ports and to allow masquerading on all ports. Add any ports created by the virtualisation host. Use system-config-firewall for this. This can be done from a GUI session or a pure command line session
  7. Restart the Zebra, OSPFD and network services service zebra restart service ospfd restart service network restart
  8. Make the services start on start-up using chkconfig chkconfig zebra on chkconfig ospfd on
  9. Test the configuration by trying to ping an IP such as 8.8.8.8
I hope this article has been helpful for you and expect some more very soon. If there are any questions or queries comment on this post, ask on the Facebook page www.facebook.com/winuxsupport or tweet @winuxsupport All feedback is welcome to improve this blog for everyone

No comments:

Post a Comment