Cause:
Linux system does not turn on the IP forwarding function by default.
Solution:
Just turn on the IP forwarding function.
Solution:
1. Confirm the status of the IP forwarding function
Use the following command to view the /proc file system,
cat /proc/sys/net/ipv4/ip_forward012
If the value in the above file is 0, it means that IP forwarding is prohibited; if it is 1, it means that the IP forwarding function has been turned on.
2. If you want to turn on the IP forwarding function, you can directly modify the above file:
echo 1 > /proc/sys/net/ipv4/ip_forward1
Change the content of the file from 0 to 1. Disabling IP forwarding changes 1 to 0.
3. The above command does not save the changes to the IP forwarding configuration. The original value will still be used the next time the system starts. To permanently modify the IP forwarding, you need to modify the /etc/sysctl.conf file. Modify the value of the following line:
net.ipv4.ip_forward = 11
4. After modification, you can restart the system to make the modification effective, or execute the following command to make the modification effective
sysctl -p /etc/sysctl.conf1
After the above configuration, IP The forwarding function is permanently enabled.
Note: centos7 operates the /usr/lib/sysctl.d/50-default.conf file
Recommended tutorial: docker tutorial
The above is the detailed content of How to solve the problem of domain name resolution failure in docker container. For more information, please follow other related articles on the PHP Chinese website!