设置主机静态IP地址(redhat5.5)

1.查看虚拟机的子网IP,网关
在这里插入图片描述
在这里插入图片描述
2.编辑配置文件

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
IPADDR=192.168.200.10
NETMASK=255.255.255.0
BROADCAST=192.168.200.255
GATEWAY=192.168.200.2
ONBOOT=yes
USERCTL=NO
BOOTPROTO=static
#HWADDR=00:0C:29:47:82:BA
TYPE=Ethernet
IPV6NIT=no
DNS1=202.96.209.5
DNS2=8.8.8.8

3.重启网络服务

[root@localhost ~]# service network restart

4.查看更改之后的IP地址

第一种:

[root@localhost ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:47:82:ba brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.10/24 brd 192.168.200.255 scope global eth0
    inet6 fe80::20c:29ff:fe47:82ba/64 scope link 
       valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop 
    link/sit 0.0.0.0 brd 0.0.0.0

第二种

[root@localhost ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:47:82:BA  
          inet addr:192.168.200.10  Bcast:192.168.200.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe47:82ba/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:53 errors:0 dropped:0 overruns:0 frame:0
          TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3273 (3.1 KiB)  TX bytes:12499 (12.2 KiB)

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:1626 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1626 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2806580 (2.6 MiB)  TX bytes:2806580 (2.6 MiB)

5.测试能否上外网
能拼通之后使用ctrl+c退出

[root@localhost ~]# ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148: icmp_seq=1 ttl=128 time=213 ms
64 bytes from 220.181.38.148: icmp_seq=2 ttl=128 time=50.7 ms
64 bytes from 220.181.38.148: icmp_seq=3 ttl=128 time=145 ms
64 bytes from 220.181.38.148: icmp_seq=4 ttl=128 time=190 ms
64 bytes from 220.181.38.148: icmp_seq=5 ttl=128 time=169 ms
64 bytes from 220.181.38.148: icmp_seq=6 ttl=128 time=187 ms

--- baidu.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 9259ms
rtt min/avg/max/mdev = 50.773/159.322/213.499/52.844 ms

设置完静态IP之后,我们就可以通过xshell来连接主机了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值