手动更改linux为静态IP 要先ifdown eth0 再修改,再ifup eth0 /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/resolv.conf /etc/hosts
以下是我的设置
1 /etc/sysconfig/network
这里主要是指定了网关
NETWORKING=yes NETWORKING_IPV6=no GATEWAY=192.168.1.1 HOSTNAME=localhost.localdomain
2 /etc/sysconfig/network-scripts/ifcfg-eth0
这里主要指定IP获得方式(static),ip地址,子网掩码,网络类型
# Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet PCI Express DEVICE=eth0 #BOOTPROTO=dhcp BOOTPROTO=static IPADDR=192.168.1.100 NETMASK=255.255.255.0 TYPE=Ethernet #HWADDR=XX:XX:XX:XX:XX:XX
MACADDR=XX:XX:XX:XX:XX:XX ONBOOT=yes
3 /etc/resolv.conf 指定DNS search localdomain nameserver 192.168.1.1 |
4 /etc/init.d/network restart.