修改服务器的值,修改Linux服务器的ttl值

本文探讨了Linux系统中修改`net.ipv4.ip_default_ttl`参数对网络连接的影响,当设置为1时导致服务器无法远程访问,但内网连接仍然可行。通过示例展示了如何查看和修改该参数,并使用`ping`和`tcpdump`工具验证其在网络通信中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[[email protected]_android_client_download ~]# cat /etc/sysctl.conf |grep net.ipv4.ip_default_ttl

net.ipv4.ip_default_ttl = 28

[[email protected]_android_client_download ~]# sysctl -p

[[email protected]_android_client_download ~]# ping 127.0.0.1 -c 1

PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=28 time=0.044 ms

--- 127.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.044/0.044/0.044/0.000 ms

#抓包  -i 指定网卡 -t 指定协议 -nv 显示详细信息

[[email protected]_android_client_download ~]# tcpdump -i eth1 -n -v -t icmp

tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes

IP (tos 0x0, ttl 28, id 0, offset 0, flags [DF], proto ICMP (1), length 84)

112.124.111.141 > 180.149.132.47: ICMP echo request, id 62590, seq 1, length 64

IP (tos 0x14, ttl 53, id 0, offset 0, flags [DF], proto ICMP (1), length 84)

180.149.132.47 > 112.124.111.141: ICMP echo reply, id 62590, seq 1, length 64

IP (tos 0x0, ttl 28, id 0, offset 0, flags [DF], proto ICMP (1), length 84)

112.124.111.141 > 180.149.132.47: ICMP echo request, id 62590, seq 2, length 64

IP (tos 0x14, ttl 53, id 0, offset 0, flags [DF], proto ICMP (1), length 84)

180.149.132.47 > 112.124.111.141: ICMP echo reply, id 62590, seq 2, length 64

如果把net.ipv4.ip_default_ttl = 1 服务器会上不去网,不能远程连接服务器,可以用内网连接,修改参数,恢复上网

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值