After resolving CentOS add a new NIC card configuration file can not be found, the configuration of multiple network adapters and static routing

Reference article

https://blog.csdn.net/qq_36512792/article/details/79787649

Use VMware Workstation virtual machine installedCentOS 7 After the virtual machine, after adding the card CentOS 7 No card configuration file problem, after adding a second card, enter the CentOS 7 the system, you do not see the network card configuration file.

Enter CentOS7 the system, use ip addr view the status as follows:

We found ens33 and ens77 have IP address, and may be used normally, ens33 used manually configured IP , ens37 using dhcp automatic acquisition of the IP address, the / etc / sysconfig / network-scripts / directory can not find ifcfg- ens37 profile

solution:

1. Use nmcli con show command to view the card's UUID information, note the UUID value

2. Use ip addr command to view the card information, write down ens37 network card MAC address

3. The / etc / sysconfig / network-scripts / directory ifcfg-ens33 copy of the document, and named the ifcfg-ens37 , re-edit the configuration file, pay attention to modify the necessary hardware information.

4. Finally, restart card required.

   

   

Add a static route

In linux add permanent static route in two ways:

   

Add routes command:

1,route add

1

2

3

4

-net 192.56.76.0 255.255.255.0 Netmask the Add route dev eth0 # Add a static route

the Add default gw 192.168.0.1 route # Add a default route

-net 192.168.1.0/24 192.168.0.1 gw del route # delete a route

-n route # View the routing table

2,ip ro add

1

2

3

4

RO the Add 192.56.76.0/24 dev 192.168.0.1 ip # Add a static route

RO default 192.168.0.1 ip the Add Via dev eth0 # Add a default route

RO del 192.168.1.0/24 ip # delete a route

Show route ip # View the routing table

   

Common parameters:

Add to add routing

del Delete route

via export gateway IP address

dev gateway exports physical device name

   

After allowing the routing restart the server remains in effect:

1, which added to the /etc/rc.local:

Add the route command is: copy command directly from the command line operations into the file, you can save out.

2, in the / etc / sysconfig / static-routes file written inside:

If the file does not exist, manually create, add content format:

/Etc/init.d/network reference file inside the shell statement:

1

2

3

4

5

6

                # Add non interface-specific static-routes.

                if [ -f /etc/sysconfig/static-routes ]; then

                   grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do

                   /sbin/route add -$args

                done

                be

Then, if you want to add a static route command is:

1

               route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0

Then, add formatting in / etc / sysconfig / static-routes file as follows:

1

               any -net 192.56.76.0 netmask 255.255.255.0 dev eth0

   

Add a static route contrast in two ways:

1,rc.local:

Reboot the server to take effect;

Restart network services, static routing failure;

rc.local script is a last run after the system starts, so if you like NFS network service requirements need to be mounted, then the way is not suitable;

2,static-routes:

Reboot the server to take effect;

Network Service Restart to take effect:

For services that require network requirements;

   

Adding script static routing methods and rc.local on the same subject:

This method is actually to write your own script, placed /etc/rc3.d/ beginning to S.

S means is activated, a sequence number, K is the stopping means.

Daemon is usually started at a startup sequence mode.

The smaller the number of sequential forward start;

/etc/rc3.d text is a multi-user environment, the general environment is the production environment.

   

It is also bad: After restarting the network failure.

   

to sum up:

If you need to add static routes, try to add static routes to / etc / sysconfig / static-routes file. Avoid restart the network service routing failure cause, in order to avoid failure.

   

   

Guess you like

Origin www.cnblogs.com/withfeel/p/11840290.html