RED-HAT系列設置:linux
linux的網卡配置文件在"/etc/sysconfig/network-script/"目錄下。bash
DEVICE=eth0 HWADDR=00:0C:29:DC:BF:57 TYPE=Ethernet UUID=8bb9e970-45fd-4007-8333-0ef5000e9603 ONBOOT=no NM_CONTROLLED=yes BOOTPROTO=dhcp
設置靜態IP:ide
DEVICE=eth0 HWADDR=00:0C:29:DC:BF:57 TYPE=Ethernet UUID=8bb9e970-45fd-4007-8333-0ef5000e9603 ONBOOT=no NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.1.100 NETMASK=255.255.255.0 GATEWAY=192.168.1.1
UBUNTU網卡設置/etc/network/intersfacesspa
dhcp獲取IP:rest
auto eth0 iface eth0 inet eth0
靜態IP:orm
auto eth0 iface eth0 inet static address 192.168.0.33 gateway 192.168.0.1 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255
添加網關ip
[root@localhost ~]# route#route add default gw192.168.1.1 刪除網關 [root@localhost ~]# route del default gw 192.168.1.1
經常使用配置網卡的命令it
ifup eth0 #打開eth0網卡ast
ifdown eth0 #關閉eth0網卡class
ifconfig #查看當前網卡信息
ifconfig -a #查看當前全部網卡信息
ifconfig eth0 192.168.1.1 #爲eth0網卡配置靜態IP
ifconfig eth0:1 192.168.2.1 #在一張網卡上配置多個IP
redhat 5.0系統主要經過network管理,6.0的則經過NetworkManager來管理
[root@localhost ~]# service network restart
[root@localhost ~]# service NetworkManager restart