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
/16
gw10.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.0
NETMASK0=255.255.0.0
GATEWAY0=10.1.1.254
ADDRESS1=172.16.0.0
NETMASK1=255.240.0.0
GATEWAY1=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