Build Linux routers based on Ubuntu

Source: Internet
Author: User
Tags nameserver

Open source, almost the meaning of omnipotent, and recently because it played hi ...


Due to business development, the need for temporary access to 300MB and gigabit routers, and the company's existing routers are hundred trillion, for cost reasons, only do not want to replace the new router, on-line check can do Linux router, because it is temporary, so do it ...

Install the system this has been skipped, go directly to the router-related configuration section:

First, select the machine

Requirements are not high, two network cards can be, other according to the actual needs of the configuration.

Second, network card settings

Edit file:/etc/network/interfaces

Auto Lo
Iface Lo inet Loopback

# IP is just an example, non-real IP

Auto Eth0
Iface eth0 inet Static
Address100.100.100.100
Gateway100.100.100.101
Netmask255.255.255.250

Auto Eth1
Iface eth1 inet Static
Address10.1.1.1
Network10.1.1.0
Broadcast10.1.1.255
Gateway10.1.1.1
Netmask255.255.255.0
Dns-nameservers10.1.1.1


After Setup, save and restart the network card service:

sudo/etc/init.d/networking restart
# or
sudoService Networking Restart

Modify DNS, edit /etc/resolvconf/resolv.conf.d/base and /etc/resolvconf/resolv.conf.d/original

NameServer8.8.8.8
NameServer114.114.114.114


Setup Complete Restart resolvconf Service

sudo /etc/init.d/resolvconf Restart

can be viewed by /etc/resolv.conf Whether the modification was successful, as follows:

# Dynamic resolv.conf (5)file forGLIBC Resolver (3) generated by resolvconf (8)
# do not EDIT this FILE by HAND--YOUR changes'll be overwritten
NameServer10.1.1.1
NameServer8.8.8.8
NameServer114.114.114.114

Third, set the route

To view the current route:

$ route
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref use Iface
Default100.100.100.101 0.0.0.0Ug000Eth0
10.1.1.0*255.255.255.0U000Eth1
100.100.100.100 *               255.255.255.250U0      0        0eth0

$route del default Dev eth1
$ route add default GW 100.100.100.101 dev eth0
$ Route add-net 100.100.100.100 netmask 255.255.255.250 Dev eth0
$ Route add-net 10.1.1.0 netmask 255.255.255.0 Dev eth1

Four, set IP packet forwarding

$sudoEcho1>/proc/sys/net/ipv4/ip_forward
$sudoVI/etc/sysctl.conf
Cancel # Net.ipv4.ip_forward =1The comment, save exit
$sudoIptables-f
$sudoIptables-p INPUT ACCEPT
$sudoIptables-p FORWARD ACCEPT
$sudoIptables-t nat-a postrouting-o Eth0-j Masquerade


At this point, the basic function of the Linux route is set to complete, other more settings can refer to the following articles:

1. UBuntu8.04 Server Setup Router

2. UBUTNU Server dual NIC network settings

Build Linux routers based on Ubuntu

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.