Archlinux设置静态固定IP
2015-06-24 22:14
826 查看
最近装了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
将其内容修改如下:
之后使用命令netctl其生效,
[root@localhost /]# netctl
enable enp0s25
重启Archlinux即可
[root@localhost /]# reboot
效果如下:
可见设置生效。
首先 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
效果如下:
可见设置生效。
相关文章推荐
- Linux 下wget 的参数描述
- linux键盘驱动详解等链接
- linux sort,uniq,cut,wc命令详解
- Linux编辑器vi使用方法详细介绍
- Linux下的GCC与G++
- 【Linux】psql: FATAL: Ident authentication failed for user "username" Error and Solution
- linux常用命令
- 在linux下搭建git环境
- Linux下socket编程
- CentOS 安装VMware Tools
- Linux下write、read方式
- CentOS 7: 设置时区和时间
- Gitlab的使用
- Linux下select应用
- Linux系统编程——vfork() 函数详解
- select详解
- wmctrl编译与使用(-)
- linux学习(之二)-初识linux的一些常用命令
- linux程序设计——执行SQL语句(第八章)
- Linux下select详解