最近装了Archlinux,可是每次开机后,设置的IP都没有了,废了好大劲才搞定,俗话说好记性不如烂笔头,特意摘录下来,已备后需。
首先 ifconfig -a 查看自己的网卡,如下
[root@localhost /]# ifconfig -a
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 3c:97:0e:78:6f:c8 txqueuelen 1000 (Ethernet)
RX packets 205 bytes 22491 (21.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 129 bytes 39400 (38.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf3a00000-f3a20000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 9c:4e:36:a3:5a:2c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
由此可以看出,第一块网卡是enp0s25,我们对其进行设置,故在/etc/netctl 下新建文件 enp0s25,并对其进行编辑:
[root@localhost /]# cd /etc/netctl/
[root@localhost /]# nano enp0s25
将其内容修改如下:
Description='enp0s25'
Interface=enp0s25
Connection=ethernet
IP=static
Address=('192.168.0.14/24')
#Routes=('192.168.0.0/24 via 192.168.0.1')
Gateway='192.168.0.1'
DNS=('192.168.0.1')
TimeoutUp=300
TimeoutCarrier=300
之后使用命令netctl其生效,
[root@localhost /]# netctl enable enp0s25
重启Archlinux即可
[root@localhost /]# reboot
效果如下:
可见设置生效。