JAVA obtains network card information and default gateway (Linux CentOS7 multi-network card)

JAVA obtains network card information and default gateway (Linux CentOS7 multi-network card)

Existing requirements: The web page can obtain the network card information and the default gateway, and the network card can be configured through the web page.

1. Prepare the required LINUX commands

Insert picture description here

2. Execute commands through RUNTIME

Insert picture description here
The above code obtains the set of network card names, and then obtains the details of the network card through the ifconfig xxx command.
Insert picture description here

3. Processing results

Insert picture description here

4. Get the default gateway (static route)

Insert picture description here
Insert picture description here

5. Test it

Insert picture description here
Insert picture description here

6. Anyway, various commands can be executed through RUNTIME, and then the processing result is connected, and it is grieving to deal with it. I don't know if there is a better way.

7. Modify the network card configuration:

JAVA modify the network card configuration (Linux CentOS7 multi-network card)
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_38045214/article/details/114640529