Mac configuration dual network card Mac uses both the internal network and the external network

When working in a company, you usually connect to the intranet, and the biggest limitation of connecting to the intranet is that you cannot use the external network. If you encounter problems, you cannot google. And when you connect to wireless, things on the intranet cannot be accessed, that is, I can't work normally. For a novice like me, I have countless problems at work and I can't ask my colleagues for advice on everything. This is really a headache~~~~

Then can we access the internal and external networks at the same time? The answer is of course yes. The solution is essentially that because the number of internal network segments is limited, so the internal network segment sets a local static route. That is, add an intranet segment pointing to the gateway of the corresponding intranet, so that all intranet segments use the corresponding intranet route, and all the default network segments use the default external network route
To put it simply, access the intranet website Use the internal network, and all other websites will use the external network by default, so that your computer can be accessed by both internal and external networks.

Here is a summary of how to configure a Mac to use the internal network and the external network at the same time. The following dual network card configuration method is for using WIFI for the external network and wired for the internal network. However, it should be noted that the dual network cards can also be wired or wireless. The essence of the configuration idea is the same.

Without further ado, please strictly follow the following steps to set up:

Step 1: Set the correct network card service sequence

Enter System Preferences - Network - Set Service Order, and drag to set network priority. Make the network card connected to the external network located above the internal network card. At this time, you can normallyaccess the external network


Step 2: Check the gateway address of the intranet network card

The router IP is the gateway address that will be used in the next step of setting
The subnet mask will also be used in the next step of setting


Step 3: Set up a local static route and add an intranet segment pointing to the gateway of the corresponding intranet.

(This step requires executing the command in the terminal of MacOS. For the method of opening the terminal, please refer to How to Open the Terminal of MacOS)
First introduce 2 commands about adding and deleting. The details are as follows: Example
Add:

sudo route add -net 10.0.0.0 -netmask 255.0.0.0 10.0.2.1
sudo route add -net 30.1.0.0 -netmask 255.255.0.0 10.0.2.1


delete:

sudo route delete -net 10.0.0.0 -netmask 255.0.0.0 10.0.2.1
sudo route delete -net 30.1.0.0 -netmask 255.255.0.0 10.0.2.1


The net parameter corresponds to the network segment IP, and netmask is the subnet mask. The last IP is the intranet gateway, which is the router IP address seen in the previous step.

For example, the URL you want to access on the intranet is http://10.90.20.27/fh, and the IP address of the intranet gateway, the router you just saw, is 172.16.84.254. Use the following commands to add and delete it
Add

sudo route add -net 10.90.20.0 -netmask 255.255.255.0 172.16.84.254

delete

sudo route delete -net 10.90.20.0 -netmask 255.255.255.0 172.16.84.254

In fact, you might as well set up all the URLs of the 10 network segments (the main thing is to pay attention to the corresponding relationship between the network segment (10.0.0.0) and the subnet mask (255.0.0.0)), and use the following command to add

sudo route add -net 10.0.0.0 -netmask 255.0.0.0 172.16.84.254

At this point, the internal and external network routing has been configured.

Step 4: Configure intranet domain name and intranet DNS resolution

In the MacOS system, it is not supported to add the internal and external DNS server addresses to the external network card at the same time to resolve the internal network address, so we need to write the internal network domain name and the corresponding IP address to the /etc/hosts file Perform local analysis in .

A more convenient method is: first turn off the external network card, enter pure intranet mode, ping the intranet domain name to obtain the intranet IP address, and then write the IP address and domain name into hosts. The steps are as follows.

Obtain the IP address of the corresponding domain name through the ping command

MacBook-Pro:root# ping aaa.bbb.com
PING aaa.bbb.com (10.12.8.25): 56 data bytes
64 bytes from 10.12.8.25: icmp_seq=0 ttl=61 time=15.934 ms
64 bytes from 10.12.8.25: icmp_seq=1 ttl=61 time=16.219 ms
64 bytes from 10.12.8.25: icmp_seq=2 ttl=61 time=15.713 ms
64 bytes from 10.12.8.25: icmp_seq=3 ttl=61 time=15.755 ms

Write the IP address and corresponding domain name into the /etc/hosts file

MacBook-Pro:root# echo "10.12.8.25 aaa.bbb.com" >>/etc/hosts    

Be careful and be careful not to make mistakes! !

At this point, the configuration has been completed. At this time, your mac can be accessed from both the internal and external networks, but please note that you need to reset it after restarting.


Original link: https://blog.csdn.net/weixin_44637703/article/details/121626312

Guess you like

Origin blog.csdn.net/BUG_delete/article/details/133270718