ubuntu配置IP
1. 修改配置文件
# vi /etc/network/interfaces
# Thisfile describes the network interfaces available on your system
# andhow to activate them. For more information, see interfaces(5).
# Theloopback network interface
auto lo
iface lo inet loopback
# Theprimary network interface
auto eth0
iface eth0 inet static
address 192.168.1.104
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-*options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8
dns-search.COM
重启网卡:
# /etc/init.d/networking restart
# service network-manager restart //新版
2. 设置临时IP地址
设置IP:sudo ifconfig eth0 192.168.22.50 netmask 255.255.255.0
设置网关:sudo route add default gw 192.168.22.1
设置NFS:修改/etc/resolv.conf
nameserver DNS的地址1
nameserver DNS的地址2完成
3. 如果出现 unknown host
ping: unknown host www.baidu.com
vi /etc/resolv.conf
nameserver 8.8.8.8
红帽配置IP
1. 配置动态IP
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=08:00:27:71:85:BD
2. 配置静态IP
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 (设备名称)
ONBOOT=yes (计算机启动时是否激活网卡,取值为:yes/no)
BOOTPROTO=none (获取IP地方法:取值为:static/bootp/dhcp)
IPADDR=192.168.1.8 (该网络接口地IP地址)
NETMASK=255.255.255.0 (子网掩码)
GATEWAY=192.168.1.1 (网关地址)
TYPE=Ethernet
USERCTL=no
PEERDNS=no
NETWORK=192.168.1.0
BROADCAST=192.168.1.255 (广播地址)
# service network restart
3. 如果出现错误
Bringing up interface eth0: Error: Connection activation failed: Device not managed by NetworkManager
# service NetworkManager stop
# service network restart