Static Routes Project

First, the project requirements:

  For network communication between different network segments A and C hosts.

Second, the deployment:

1, NIC configuration

A: 10.0.0.11 (nat mode)

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33      ifdown-post      ifup-bnep   ifup-routes
ifcfg-ens33.bak  ifdown-ppp       ifup-eth    ifup-sit
...    
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bak 
[root@localhost network-scripts]# cat ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
DEVICE="ens33"
ONBOOT="yes"
ZONE=public
IPADDR=10.0.0.11
NETMASK=255.255.255.0
GATEWAY=10.0.0.2
DNS1=10.0.0.2
[root@localhost network-scripts]# systemctl restart network
[root@localhost network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:ea:fd:0e brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.11/24 brd 10.0.0.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::4ca4:a8cc:7541:b78f/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

B: 10.0.0.12 (nat mode) & 192.168.0.12 (LAN segment)

C: 192.168.0.13 (LAN segment)

  B, C A host with the same host, backup configuration file, modify the network card configuration files, reboot the host and view.

2, network testing

  ping command to test

3, B core opening host forwarding, A, C host routing information added

主机B:
[root@localhost network-scripts]# echo 1 > /proc/sys/net/ipv4/ip_forward
主机A:
[root@localhost network-scripts]# ip route add 192.168.0.0/24 via 10.0.0.12
Host C: 
[root @ localhost Network-scripts] # ip route 192.168.0.12 Via the Add 10.0.0.0/24

  You can use iftop to monitor real-time traffic card

Third, the problem summary

1, enterprise network troubleshooting:

(1) hardware environment

  1) Check the transmission media: cable (NIC lights off)

  2) to see if communication with the gateway: ping 10.0.0.1 or 10.0.0.254

  3) Check whether communication with the public network: ping public IP (123.57.47.100)

  4) ping domain: ping www.baidu.com (if different, check DNS)

(2) Software Environment

  1) System Version: CentOS7.6

  2) network commands:

    Check whether the network communication: ping

    View the routing table: route -n

    Add a static route: route add or ip route add

    Open kernel forwarding: echo 1> / proc / sys / net / ipv4 / ip_forward (temporary open)

           echo "net_ipv4.ip_forward = 1" >> /etc/sysctl.conf (permanent)

2, enterprise-wide implementation of the project:

(1) Any change the configuration file, and then modify the first backup (backup address: the parent directory or the user's home directory / backup or root / backup)

(2) companies generally do not have root privileges, sudo need to put right.

(3) When xshell remote connection server, caution copy and paste (format might be a problem), tab bar is best connected to a server (command wrong location problem may occur)

(4) When modifying multiple network cards, network cards copy the configuration file, UUID parameter you want to modify.

3, naming format real server Note card: ifcfg-em1 or ifcfg-eth1 etc. (ifcfg-ens33 virtual machine) (server type)

4, will have to manually configure a fixed IP address

TYPE="Ethernet"
BOOTPROTO="none" #或者 static
NAME="ens33"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=10.0.0.11
NETMASK=255.255.255.0
GATEWAY=10.0.0.2
DNS1=10.0.0.2

   Uppercase command mode ZZ can save and exit

Guess you like

Origin www.cnblogs.com/renyz/p/11800777.html