centos 内网ip 设置_【已解决】CentOS中如何查看主机的内网IP和外网IP

折腾:

期间,想要了解此处买到的百度的云服务器的CentOS中的内网IP和外网IP

再去搜:

centos 查看ip

参考:

去试试:

[root@instance-jb4q99qd ~]# ifconfig | grep broadcast

inet 192.168.0.4  netmask 255.255.240.0  broadcast 192.168.15.255

[root@instance-jb4q99qd ~]#

[root@instance-jb4q99qd ~]# ifconfig -a

eth0: flags=4163  mtu 1400

inet 192.168.0.4  netmask 255.255.240.0  broadcast 192.168.15.255

inet6 fe80::f816:3eff:fe65:1b39  prefixlen 64  scopeid 0x20

ether fa:16:3e:65:1b:39  txqueuelen 1000  (Ethernet)

RX packets 15232  bytes 22401678 (21.3 MiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 11971  bytes 3707501 (3.5 MiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536

inet 127.0.0.1  netmask 255.0.0.0

inet6 ::1  prefixlen 128  scopeid 0x10

loop  txqueuelen 1  (Local Loopback)

RX packets 6  bytes 518 (518.0 B)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 6  bytes 518 (518.0 B)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@instance-jb4q99qd ~]# curl ifconfig.me

106.12.26.141

另外,本地电脑直接打开:

也可以看到类似信息:

所以再去BCC主机中试试其他命令:

[root@instance-jb4q99qd ~]# curl ifconfig.me

106.12.26.141

[root@instance-jb4q99qd ~]# curl ifconfig.me/host

[root@instance-jb4q99qd ~]# curl ifconfig.me/ua

curl/7.29.0

[root@instance-jb4q99qd ~]#  curl ifconfig.me/port

43114

[root@instance-jb4q99qd ~]# curl ifconfig.me/lang

[root@instance-jb4q99qd ~]# curl ifconfig.me/mime

*/*

[root@instance-jb4q99qd ~]# curl ifconfig.me/all

ip_addr: 106.12.26.141

remote_host:

user_agent: curl/7.29.0

port: 48866

lang:

connection:

keep_alive:

encoding:

mime: */*

charset:

via:

forwarded:

[root@instance-jb4q99qd ~]# curl ifconfig.me/all.json

{“connection”:””,”ip_addr”:”106.12.26.141″,”lang”:””,”remote_host”:””,”user_agent”:”curl/7.29.0″,”charset”:””,”port”:”43124″,”via”:””,”forwarded”:””,”mime”:”*/*”,”keep_alive”:””,”encoding”:””}

[root@instance-jb4q99qd ~]# curl ifconfig.me/all.xml

106.12.26.141

*/*

48870

curl/7.29.0

[root@instance-jb4q99qd ~]#

【总结】

CentOS 7中查看当前主机:内网IP:ifconfig -a

输出结果中的broadcast的部分

此处结果是:192.168.15.255

外网IP:通过访问别的查询网站而获得当前的外网IP,比如:curl ifconfig.me

此处结果是:106.12.26.141

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值