Debian/Ubuntu RedHat/CentOS Linux 网卡配置
Debian/Ubuntu 网卡配置
请先停止 NetworkManager 这个搅屎棍1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48先临时设定ip,然后登陆上去
root@ubuntu:~# ifconfig eth0 10.11.12.2/24
root@raspberrypi:~# vim /etc/network/interfaces
#auto eth0
#allow-hotplug eth0
#iface eth0 inet manual
auto eth0
iface eth0 inet static
address 10.11.12.19
netmask 255.255.255.0
gateway 10.11.12.13
dns-nameservers 180.76.76.76 223.5.5.5
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
root@raspberrypi:~#
重启网络
root@ubuntu:~# ifdown eth0 && ifup eth0
或者:
root@raspberrypi:~# /etc/init.d/networking restart
测试
root@raspberrypi:~# ping www.baidu.com
PING www.a.shifen.com (115.239.210.27) 56(84) bytes of data.
64 bytes from 115.239.210.27: icmp_seq=1 ttl=57 time=2.76 ms
64 bytes from 115.239.210.27: icmp_seq=2 ttl=57 time=2.78 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.761/2.770/2.780/0.053 ms
root@raspberrypi:~#
Debian/Ubuntu 网卡别名
1 |
|
Redhat/CentOS 配置网卡
1 |
|
我的CentOS7网卡配置1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41[root@localhost network-scripts]# cat ifcfg-*
# 逻辑桥
供 KVM众多虚拟机使用, 供OpenVPN虚拟网络使用,
TYPE="Bridge"
BOOTPROTO="dhcp"
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
MACADDR=8C:89:A5:1D:FA:DC
DEVICE="br0"
ONBOOT="yes"
# 物理接口
# 搭在桥上, 让桥上的所有对象拥有 二层网络寻址功能
TYPE="Ethernet"
BOOTPROTO=manual
NAME="em1"
DEVICE="em1"
UUID="3a67e7d9-3ba7-486a-b9be-6f51c5243bc0"
IPV4_FAILURE_FATAL=no
ONBOOT="yes"
BRIDGE=br0
ETHTOOL_OPTS="speed 1000 duplex full autoneg off"
# 逻辑接口,TAP 类型, 搭到桥上
TYPE="Tap"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
NAME="tap0"
MACADDR=AB:89:AB:1D:AB:DC
DEVICE="tap0"
ONBOOT="yes"
BRIDGE=br0
[root@localhost network-scripts]#