最近在家里折腾老电脑,作为局域网内服务器,帮我提供优质的网络服务.记录一下,备忘.

Centos 7 (最小化安装)

查看网卡信息

首先获取网卡信息

ip add

例如我的电脑,返回如下.不同的电脑硬件不同,返回的信息也不尽相同.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:27:13:b7:0e:7a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.231/24 brd 192.168.1.255 scope global enp0s25
       valid_lft forever preferred_lft forever
    inet6 fd32:6c44:c27f:0:227:13ff:feb7:e7a/64 scope global mngtmpaddr dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::227:13ff:feb7:e7a/64 scope link
       valid_lft forever preferred_lft forever
3: wlp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:26:c7:50:b4:b8 brd ff:ff:ff:ff:ff:ff

例如我的电脑,有线网卡名称为enp0s25,无线网卡名称为wlp3s0.

配置网卡开启网络连接

进入/etc/sysconfig/network-scripts目录,编辑ifcfg-enp0s25这个文件.

ONBOOT的值改为yes.添加mac地址

HWADDR=00:27:13:b7:0e:7a

保存退出后,重启网络服务.

systemctl restart network

Ubuntu Server

以DHCP方式配置网卡

编辑/network/interfaces这个文件.网卡信息获取方式同centos.

auto enp0s25
iface enp0s25 inet dhcp

保存退出后重启网络服务.

/etc/init.d/networking restart