Configure routes and default gateways for CentOS basic networks

Source: Internet
Author: User

Configure routes and default gateways for CentOS basic networks

1. View routes

Enter

netstat-r

Or

route

Command to view the active routes in the system

2. Add routes

(1) Input

routeadd-net192.168.0.0/16gw10.1.1.254

This method becomes invalid after the system is restarted. Add this row in rc. local;

(2) set the system default gateway in the/etc/sysconfig/network File

GATEWAY=192.168.0.1

(3) for a single NIC/etc/sysconfig/network-scripts/ifcfg-eth0 set their own different default gateway

GATEWAY=192.168.0.1

(4) set multiple routing networks for a single NIC/etc/sysconfig/network-scripts/eth0.route

ADDRESS0=192.168.0.0NETMASK0=255.255.0.0GATEWAY0=10.1.1.254ADDRESS1=172.16.0.0NETMASK1=255.240.0.0GATEWAY1=10.1.1.254

Changes to files take effect,

Method (2) restart the system network service

servicenetworkrestart

Method (3) (4) restart a single Nic.

ifdowneth0&&ifupeth0

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.