首页 > 解决方案 > 如何对 /etc/network/interface 进行排序?

问题描述

我是新手,我需要使用 /etc/network/interfaces 文件订购环回、静态、dhcp,如下静态地址:

auto eth1
iface eth1 inet static
address 192.168.11.3
netmask 255.255.255.0
gateway 192.168.11.1

它看起来像这样:

Interface=eth1, Type=Static, Direction=192.168.11.3, Mask=255.255.255.0, Gateway=192.168.11.1

对于 dhcp 地址:

auto eth0
iface eth0 inet dhcp

它看起来像这样:

Interface=eth0, Type=Dhcp

对于环回:

auto lo
iface lo inet loopback

它看起来像这样:

Interface=lo, Type=loopback

我尝试如下解决它,但它不起作用

if [ grep -r "static" /etc/network/interfaces ]; then
     gawk '{print "Interface=" $2 ", " "Type=" "Static" ", " "Direction=" $2 ", " "Mask=" $2 ", " "Gateway=" $2}' /etc/network/interfaces

标签: bashshell

解决方案


推荐阅读