Ubuntu Configuring static Routes

Source: Internet
Author: User

Internet------(eth1) router1 (eth2)------(eth1) router2 (eth0)------(eth0) Router3 (eth1)------(eth0) PC

Above is my network topology, where Router 1 is used to connect to the external network of a Linux machine, all the routers in the diagram are ordinary PC, these PCs are installed Ubuntu desktop system, in addition to the right-most PC, the rest of the PC has installed 3 network card (one of the spare).

Because the Debian network NIC configuration is very different from the Redhat system, Redhat is placed in a large pile of files under the/etc/sysconfig/network-scripts directory. And the Debian System network card configuration is the existence of/etc/network/interfaces this file, and no matter how many network card you have, the system will put all the configuration in this file. Let's take a look at the contents of this file.

First, let's look at the configuration of Router1:

Auto Lo
Iface Lo inet Loopback
Iface Lo inet6 Loopback
Auto Eth0
Iface eth0 inet Static
Address 192.168.2.1
Network 192.168.2.0
Netmask 255.255.255.0
Broadcast 192.168.2.255
Up Route add-net 192.168.3.0 netmask 255.255.255.0 GW 192.168.2.2
Down Route del-net 192.168.3.0 netmask 255.255.255.0 GW 192.168.2.2
Up Route add-net 192.168.4.0 netmask 255.255.255.0 GW 192.168.2.2
Down Route del-net 192.168.4.0 netmask 255.255.255.0 GW 192.168.2.2
Iface eth0 Inet6 Static
Address 2000:2::1
Netmask 64
Up route-a inet6 add 2000:3::/64 GW 2000:2::2
Up route-a inet6 add 2000:4::/64 GW 2000:2::2
Down route-a inet6 del 2000:3::/64 GW 2000:2::2
Down route-a inet6 del 2000:4::/64 GW 2000:2::2
Auto Eth1
Iface eth1 inet DHCP

In the above configuration,

Auto indicates that the LO interface and the Eth0 interface will be automatically configured when the system starts, and Lo is a local loopback (loopback) address, where V4 and V6 are set respectively two loopback;static instructions this is a static IP configuration The function behind the configuration is to add two static routes when the interface is enabled, and delete the two routing configurations when the interface is disabled. As for configuring routing, it is the same as the route command under CMD Line (except for the start up).

The eth1 behind is connected to the outside Internet, so it uses DHCP connected to the outside.

After the router is properly equipped with this file, it also needs to enable its own IP forwarding, which requires entering into the/etc/sysctl.conf file, adding net.ipv4.ip_forward=1, and Net.ipv6.default.ip_ Forward=1 these two words. After exiting, then Sysctl-p/etc/sysctl.conf. This turns on IP forwarding.

With good forwarding, but also can not go to the Internet, but router have been able to ping each other, this need to configure the DNS server on each router, need to add the appropriate information in/etc/resolv.conf:

Search test.com
NameServer *.*.*.*

After that, the following routers can find router1 based on their DFT GW and get contact with the Internet.

If you want to be equipped with IPv6 multicast, which is the use of mrd6 this software to achieve, the specific configuration method is very simple, you just have to install the Deb package, and then configure mrd.conf this file is OK. It is OK to run as long as Sudo mrd6 is in the folder with mrd.conf files.

The rest of the router configuration is probably the same as the Router1, and the PC differs from this

Ubuntu Configuring static Routes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.