SUSE12配置静态IP


我的网站: https://pythoneers.cn

1. 设置虚拟网络

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2. 查看服务器使用的网卡
linux-5627:~ # ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:A7:A1:08  
          inet addr:10.0.0.130  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea7:a108/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:300 errors:0 dropped:0 overruns:0 frame:0
          TX packets:253 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27374 (26.7 Kb)  TX bytes:24570 (23.9 Kb)

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:65536  Metric:1
          RX packets:44 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3060 (2.9 Kb)  TX bytes:3060 (2.9 Kb)
3. 修改网卡对应的配置文件
linux-5627:~ # vim /etc/sysconfig/network/ifcfg-eth0 

BOOTPROTO=''
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''
MTU=''
NAME=''
NETMASK=''
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
DHCLIENT_SET_DEFAULT_ROUTE='yes'
~                                                                                                                                                                                   
~                                                                                                                                                                               "/etc/sysconfig/network/ifcfg-eth0" 11L, 186C

设置BOOTPROTO,IPADDR和NETMASK:

BOOTPROTO='static' 
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR='10.0.0.8'
MTU=''
NAME=''
NETMASK='255.255.255.0'
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
DHCLIENT_SET_DEFAULT_ROUTE='yes'
4. 设置网关
linux-5627:~ # vim /etc/sysconfig/network/routes

default 10.0.0.254 - -

如果routes文件不存在,新建即可!

5. 设置DNS
linux-5627:~ # vim /etc/resolv.conf 

#     NETCONFIG_DNS_FORWARDER
# or disable DNS configuration updates via netconfig by setting:
#     NETCONFIG_DNS_POLICY=''
#
# See also the netconfig(8) manual page and other documentation.
#
# Note: Manual change of this file disables netconfig too, but
# may get lost when this file contains comments or empty lines
# only, the netconfig settings are same with settings in this
# file and in case of a "netconfig update -f" call.
#
### Please remove (at least) this line when you modify the file!
nameserver 119.29.29.29
nameserver 114.114.114.114
nameserver 8.8.4.4 

这里设置一个可用的DNS服务器就可以了。119.29.29.29是腾讯的DNS服务器地址,后面两个是美国的DNS服务器地址。

6. 重启网卡测试网络情况
linux-5627:~ # service network restart
linux-5627:~ # ping www.huawei.com
PING www.huawei.com.lxdns.com (45.124.125.75) 56(84) bytes of data.
64 bytes from 45.124.125.75: icmp_seq=1 ttl=128 time=4.78 ms
64 bytes from 45.124.125.75: icmp_seq=2 ttl=128 time=6.70 ms
64 bytes from 45.124.125.75: icmp_seq=3 ttl=128 time=5.59 ms
64 bytes from 45.124.125.75: icmp_seq=4 ttl=128 time=6.59 ms
^C
--- www.huawei.com.lxdns.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3034ms
rtt min/avg/max/mdev = 4.789/5.921/6.702/0.783 ms
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页