Linux网络属性配置(3): 修改配置文件–>CentOS6
IP、MASK、GW、DNS相关配置文件:/etc/sysconfig/network-scripts/ifcfg 路由相关的配置文件:/etc/sysconfig/network-scripts/route-IFACE /etc/sysconfig/network-scripts/ifcfg-IFACE: DEVICE:此配置文件应用到的设备; HWADDR:对应的设备的MAC地址; BOOTPROTO:激活此设备时使用的地址配置协议,常用的dhcp, static-->静态, none-->static, boo-->引导协议: NM_CONTROLLED:NM是NetworkManager的简写;此网卡是否接受NM控制; CentOS6建议为“no”; ONBOOT:在系统引导时是否激活此设备; TYPE:接口类型;常见有的Ethernet, Bridge; UUID:设备的惟一标识; IPADDR:指明IP地址; NETMASK:子网掩码: GATEWAY:默认网关: DNS1:第一个DNS服务器指向; DNS2:第二个DNS服务器指向; USERCTL:普通用户是否可控制此设备; PEERDNS:如果BOOTPROTO的值为“dhcp”,是否允许dhcp server分配的dns服务器指向信息直接覆盖至/etc/resolv.conf文件中; ❤❤❤CentOS5-network❤❤❤ ❤❤❤CentOS6-NetworkManager❤❤❤ [root@localhost network-scripts]# cat ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet UUID=840aafa6-9d45-43a1-ba88-dd3be9f3ff1e ONBOOT=no NM_CONTROLLED=yes--> BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0" HWADDR=08:00:27:B5:54:45 IPADDR=192.168.1.3 PREFIX=24 LAST_CONNECT=1469694394 tp; ❤❤❤需要使用service network restart-->/etc/rc.d/init.d/network start❤❤❤ 路由配置文件: etc/sysconfig/network-scripts/route-IFACE 两种风格: (1) TARGET via GW 192.168.0.0/24 via 192.168.1.1 [root@localhost ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 192.168.0.0 192.168.1.1 255.255.255.0 UG 0 0 0 eth0 (2) 每三行定义一条路由 ADDRESS#=TARGET NETMASK#=mask GATEWAY#=GW 给网卡配置多地址: ifconfig: ifconfig IFACE_ALIAS ip ip addr add 配置文件: ifcfg-IFACE_ALIAS DEVICE=IFACE_ALIAS 注意:网关别名不能使用dhcp协议引导; Linux网络属性配置的tui(text user interface): system-config-network-tui 也可以使用setup调用!!!! 切记:以上必须要重启网络服务方能生效; 配置当前主机的主机名: hostname [HOSTNAME] 修改配置文件: /etc/sysconfig/network HOSTNAME= [root@localhost sysconfig]# cat network NETWORKING=yes HOSTNAME=wanghongkai 网络接口识别并命名相关的udev配置文件: /etc/udev/rules.d/70-persistent-net.rules [root@localhost rules.d]# cat 70-persistent-net.rules # This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device 0x8086:0x100e (e1000) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b5:54:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" 卸载网卡驱动: modprobe -r e1000 装载网卡驱动: modprobe e1000
原创文章,作者:wostop,如若转载,请注明出处:http://www.178linux.com/26757