初次尝试可以使用Docker的小型Linux,看了大部分Linux网络配置的文章都是修改/etc/sysconfig/network-scripts/ifcfg-eth0文件的,但Alpine Linux没有这样的配置方式,搜了下"Alpine Linux network configure",找到了alpine wiki的网络配置部分,根据自己的需求配置了一遍,在此记录下。
echo ‘slave1‘ > /etc/hostname
hostname -F /etc/hostname #立即生效
修改/etc/hosts文件:
192.168.1.150 shortname.domain.com
添加文件 /etc/network/interfaces:
auto lo
iface lo inet loopback
即可设置IPv4的loopback地址127.0.0.1
以eth0为例:
auto eth0
auto eth0
之后添加:iface eth0 inet static
address 192.168.1.150
netmask 255.255.255.0
gateway 192.168.1.1
修改/etc/resolv.conf文件:
nameserver 114.114.114.114
nameserver 114.114.115.115
ip和gateway也可以像其他Linux一样通过命令的方式临时配置:
ifconfig eht0 192.168.1.150 netmask 255.255.255.0 up
route add default gw 192.168.1.1
原文:https://www.cnblogs.com/peanutk/p/13094935.html