Linux系统配置网卡方法
方法一:通过setup命令设置网卡
[[email protected] ~]# setup
图1-1 选择network configuration
图1-2 选择pevice configurarion
图1-3选择eth0表示一定块网卡
图1-4 配置IP地址、子网掩码、网关、DNS
图1-5 选择save
图1-6 选择save&quit
方法二:修改配置文件 /etc/sysconfig/network-scripts/ifcfg-eth0 设置永久生效IP地址
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 #设备名
HWADDR=00:0C:29:9D:5E:9D #MAC地址
TYPE=Ethernet #以太网络
UUID=17d2fd2e-3b4d-4853-ae44-94d3990b86d0 #网卡UUID(唯一标识号)
ONBOOT=yes #是否开启启动网卡(yes)
IPADDR=192.168.1.11 #IP地址
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.1.8 #网关
DNS1=202.96.128.143 #DNS
NM_CONTROLLED=yes #实时生效,修改后无需要重启网卡立即生效。
BOOTPROTO= static #指定方式获取IP地址static(静态)dhcp(动态)none(不指定)
[[email protected] ~]# /etc/init.d/network restart #重新启动网卡
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/7
[ OK ]
[[email protected] ~]# ping www.baidu.com #ping 外网是否通
PING www.a.shifen.com (119.75.218.70) 56(84) bytes of data.
64 bytes from 119.75.218.70: icmp_seq=1 ttl=54 time=43.0 ms
64 bytes from 119.75.218.70: icmp_seq=2 ttl=54 time=43.3 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1779ms
rtt min/avg/max/mdev = 43.084/43.197/43.310/0.113 ms
重启网卡方法
方法一:
ifdown eth0
ifup eth0
方法二:
/etc/init.d/network restart
方法三:
service network restart
关闭网卡方法
方法一:
ifdown eth0
方法二:
/etc/init.d/network stop
方法三:
service network stop