设置固定ip地址
外网设置
vim /etc/sysconfig/network-scripts/ifcfg-eth0修改为
DEVICE=eth0 BOOTPROTO=static ONBOOT=yes NETWORKING=yes IPADDR=192.168.51.119 NETMASK=255.255.255.0 GATEWAY=192.168.51.1
内网设置
vim /etc/sysconfig/network-scripts/ifcfg-eth1修改为
DEVICE=eth1 BOOTPROTO=static ONBOOT=yes IPADDR=10.0.0.1 NETMASK=255.255.255.0
设置DNS
vim /etc/resove.conf修改nameserver
nameserver 192.168.0.230 nameserver 8.8.8.8
重启网络设置
service network restart检查ip设置
ifconfig成功会显示如下内容
eth0 Link encap:Ethernet HWaddr 1C:6F:65:84:FF:47 inet addr:192.168.51.119 Bcast:192.168.51.255 Mask:255.255.255.0 inet6 addr: fe80::1e6f:65ff:fe84:ff47/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:292621 errors:0 dropped:0 overruns:0 frame:0 TX packets:55865 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:94261095 (89.8 MiB) TX bytes:6121490 (5.8 MiB) Interrupt:225 Base address:0xe000 eth1 Link encap:Ethernet HWaddr 34:08:04:30:F1:F9 inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::3608:4ff:fe30:f1f9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5279 errors:0 dropped:0 overruns:0 frame:0 TX packets:4748 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:583448 (569.7 KiB) TX bytes:1826291 (1.7 MiB) Interrupt:233 Base address:0x4000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1125 errors:0 dropped:0 overruns:0 frame:0 TX packets:1125 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1959465 (1.8 MiB) TX bytes:1959465 (1.8 MiB)
在这里需要注意下ecos01这台机器的默认网关为192.168.51.1
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 192.168.51.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1 0.0.0.0 192.168.51.1 0.0.0.0 UG 0 0 0 eth0
服务器网络配置是相同的, 这里以10.0.0.2机器为例
设置固定ip地址
vim /etc/sysconfig/network-scripts/ifcfg-eth0修改为
DEVICE=eth0 BOOTPROTO=static ONBOOT=yes NETWORKING=yes IPADDR=10.0.0.2 NETMASK=255.255.255.0 GATEWAY=10.0.0.1
设置DNS
vim /etc/resove.conf修改nameserver
nameserver 192.168.0.230 nameserver 8.8.8.8
重启网络设置
service network restart检查ip设置
ifconfig成功会显示如下内容
eth0 Link encap:Ethernet HWaddr 14:FE:B5:EB:82:7B inet addr:10.0.0.2 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::16fe:b5ff:feeb:827b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4711306 errors:0 dropped:0 overruns:0 frame:0 TX packets:4552242 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:425097137 (405.4 MiB) TX bytes:403439468 (384.7 MiB) Memory:f7ae0000-f7b00000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:68209 errors:0 dropped:0 overruns:0 frame:0 TX packets:68209 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:23503806 (22.4 MiB) TX bytes:23503806 (22.4 MiB)