Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Quagga to realize Linux dynamic routing

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use Quagga to implement Linux dynamic routing. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

OSPF means the shortest path first Open Shortest Path First. OSPF is an Interior Gateway Protocol (IGP); it can be used in LAN and LAN interconnection across the Internet. Each OSPF router in your network contains the topology of the entire network and calculates the shortest path through the network. OSPF automatically propagates the network changes it detects through multicasting. You can divide your network into areas to keep the routing table manageable; routers in each area only need to know the next-hop interface address of the area that leaves it, rather than recording the entire routing table of your network.

RIP, the routing information protocol, is an old protocol in which RIP routers periodically broadcast its entire routing table into the network, rather than just multicast network changes like OSPF. RIP measures routes by the number of hops, and any route that exceeds 15 hops is considered unreachable. RIP setup is simple, but OSPF is better in terms of speed, efficiency, and resilience.

BGP-4 is version 4 of the Border Gateway Protocol. This is the external Gateway Protocol (EGP) for Internet traffic routing. You won't use BGP unless you are an Internet service provider.

Prepare to use OSPF

In our small KVM test lab, we use two virtual machines to represent two different networks, and then configure the other virtual machine as a router. Create two networks: net1 is 192.168.110.0 Universe 24, and net2 is 192.168.120.0 Universe 24. It is wise to enable DHCP, otherwise you will have to go to each of these three virtual machines and set static addresses for them. Host 1 is in net1, Host 2 is in net2, and the router is connected to both networks. Set the gateway address of Host 1 to 192.168.110.126 and the gateway address of Magi Host 2 to 192.168.120.136.

Host 1: 192.168.110.125

Host 2:192.168.120.135

Router:192.168.110.126 and 192.168.120.136

Install Quagga on the router. It is the quagga package in most Linux. There is also a separate documentation package quagga-doc on Debian. Uncomment the following line in the / etc/sysctl.conf configuration file to enable packet forwarding:

Net.ipv4.ip_forward=1

Then, run the sysctl-p command to make the changes take effect.

Configure Quagga

Check out the sample configuration file in your Quagga package, for example, / usr/share/doc/quagga/examples/ospfd.conf.sample. Unless your version of Linux is innovative to your liking, the configuration file should normally be in the / etc/quagga directory. Most Linux versions have two files in this directory, vtysh.conf and zebra.conf. They provide the minimum configuration required for the daemon to run. Unless your distribution has some special configuration, zebra always runs first, and when you start ospfd, it starts automatically. Debian/Ubuntu is a special case, which we will talk about later.

Each router daemon will read its own configuration file, so we must create / etc/quagga/ospfd.conf and enter the following:

! / etc/quagga/ospfd.confhostname router1log file / var/log/quagga/ospfd.logrouter ospf ospf router-id 192.168.110.15 network 192.168.110.0/0 area 0.0.0.0 network 192.168.120.0/0 area 0.0.0.0access-list localhost permit 127.0.0.1/32access-list localhost deny anyline vty access-class localhost

You can use an exclamation point (!) or a pound sign (#) to comment out these lines. Let's take a quick look at these options.

Hostname can be anything you want. These are not Linux hostnames in the general sense, but you will see them when you log in using vtysh or telnet.

Log file is any file you want to use to save logs.

Router specifies the routing protocol.

Ospf router-id is any 32-digit number. Using an IP address of the router is a good choice.

Network defines the networks your router wants to advertise.

Access-list restricts vtysh login, which is the Quagga command line shell, which allows local machines to log in and denies any remote administration.

Debian/Ubuntu

Before you start the daemon, Debian/Ubuntu may need one or more steps more than other Debian derivatives. Edit / etc/quagga/daemons, except for zebra=yes and ospfd=yes, so that the value of all other rows is no.

Then, run ospfd on Debian to start Quagga:

# systemctl start quagga

On most other Linux, including Fedora and openSUSE, start ospfd with the following command:

# systemctl start ospfd

Host 1 and Host 2 will now be able to ping each other and the router.

A lot of space is spent here to describe very simple settings. In reality, the router will connect two switches and then provide a gateway for all computers connected to the switch. You can also add more network interfaces to your router so that your router can provide routing services for more networks, or you can connect directly to other routers or to the backbone network that connects to other routers.

You may not want to go to the trouble of manually configuring the network interface. The easiest way is to use your DHCP server to announce your router. If you use Dnsmasq, you have an integrated solution of DHCP and DNS.

Thank you for reading! This is the end of the article on "how to use Quagga to achieve Linux dynamic routing". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report