archlinux官方使用了netctl替代netcfg工具,更适合配合systemd使用

https://www.archlinux.org/news/netctl-is-now-in-core/


[code]

sudo netctl enable ethernet-master 自动通过systemctl设置自动启 动

sudo netctl start ethernet-master 手工命令行启动服务

sudo netctl status ethernet-master 查看状态

[/code]


文件位置 /etc/netctl/ethernet-master


[code]

Connection='ethernet'

Description='A basic static ethernet connection using iproute'

Interface='eth0'

IP='static'


#默认Ip地址

Address=('192.168.1.123/24')


#配置编辑文件名 /usr/lib/network/ip


MyGateway="192.168.1.1"

MyIpAlias1="192.168.3.123/24"

MyIpAlias2="192.168.1.122/24"


#使用iproute工具配置ip 地址,采用别名方式 并添加默认路由

IPCustom=("link set dev ${Interface} up" "addr add dev ${Interface} local ${MyIpAlias1} brd + label ${Interface}:1" "addr add dev ${Interface} local ${MyIpAlias2} brd + label ${Interface}:2" "route add default via ${MyGateway} dev ${Interface}")



#禁用原因 提示出错

#Gateway='192.168.1.1'


#禁用原因 会修改 /etc/resolv.conf

#DNS=('192.168.1.1')

#调用systemd中的命令工具hostnamectl进行设置主机名

#Hostname="myhost"

[/code]