ipv4

how to force python httplib library to use only A requests

依然范特西╮ 提交于 2019-11-29 08:40:43
The problem is that urllib using httplib is querying for AAAA records. I would like to avoid that. Is there a nice way to do that? >>> import socket >>> socket.gethostbyname('www.python.org') '82.94.164.162' 21:52:37.302028 IP 192.168.0.9.44992 > 192.168.0.1.53: 27463+ A? www.python.org. (32) 21:52:37.312031 IP 192.168.0.1.53 > 192.168.0.9.44992: 27463 1/0/0 A 82.94.164.162 (48) python /usr/lib/python2.6/urllib.py -t http://www.python.org >/dev/null 2>&1 21:53:44.118314 IP 192.168.0.9.40669 > 192.168.0.1.53: 32354+ A? www.python.org. (32) 21:53:44.118647 IP 192.168.0.9.40669 > 192.168.0.1.53:

在Linux中打开了太多文件(Too many open files)的三种解决方法

与世无争的帅哥 提交于 2019-11-29 08:19:11
在Linux中打开了太多文件(Too many open files)的三种解决方法 回答一、 [root@lxadmin nginx]# cat /proc/sys/fs/file-max 8192 文件系统最大可打开文件数 [root@lxadmin nginx]# ulimit -n 1024 程序限制只能打开1024个文件 使用[root@lxadmin nginx]# ulimit -n 8192调整一下 或者永久调整打开文件数 可在启动文件/etc/rc.d/rc.local末尾添加(在/etc/sysctl.conf末尾添加fs.file-max=xxx无效) ulimit -n 8192 回答二、 Linux内核有时会报告“Too many open files”,起因是file-max默认值(8096)太小。要解决这个问题,可以root身份执行下列命令(或将它们加入/etc/rcS.d/*下的init脚本。) # echo "65536" > /proc/sys/fs/file-max # 适用于2.2和2.4版内核 # echo "131072" > /proc/sys/fs/inode-max # 仅适用于2.2版内核 回答三、 办法是修改操作系统的打开文件数量限制,方法如下: 1. 按照最大打开文件数量的需求设置系统, 并且通过检查/proc/sys/fs

IPV6地址表示详解(转)

痴心易碎 提交于 2019-11-29 08:19:00
IPv6是互联网协议的第六版;最初它在IETF的 IPng选取过程中胜出时称为互联网新一代网际协议(IPng),IPv6是被正式广泛使用的第二版互联网协议。 现有标准IPv4只支持大概40亿(4×109)个网络地址,而IPv6支持3.4 ×1038个,这等价于在地球上每平方英寸有4.3×1020地址(6.7×1017地址/mm2)。(IPv5不是IPv4的继承,而是实验性的面向流的数据流协议,用来对声音,图像等提供支持。) IPv6地址表示 IPv6地址为128位长,但通常写作8组,每组为四个十六进制数的形式。例如: 2001:0db8:85a3:08d3:1319:8a2e:0370:7344 是一个合法的IPv6地址。 如果四个数字都是零,可以被省略。例如: 2001:0db8:85a3:0000:1319:8a2e:0370:7344 等价于 2001:0db8:85a3::1319:8a2e:0370:7344 遵从这些规则,如果因为省略而出现了两个以上的冒号的话,可以压缩为一个,但这种零压缩在地址中只能出现一次。因此: 2001:0DB8:0000:0000:0000:0000:1428:57ab 2001:0DB8:0000:0000:0000::1428:57ab 2001:0DB8:0:0:0:0:1428:57ab 2001:0DB8:0::0:1428:57ab

Centos7.6多网卡多IP配置

半世苍凉 提交于 2019-11-29 04:59:59
1.进入网卡配置文件 cd /etc/sysconfig/network-scripts/ 2.创建新网卡的配置文件 ifcfg-eth1 cp ifcfg-eth0 ifcfg-eth1 这样副网卡配置文件生成了,下面是详细配置 3.ifcfg-eth0配置 # Created by cloud-init on instance boot automatically, do not edit. # BOOTPROTO=static DEVICE=eth0 HWADDR=52:54:00:17:f0:c8 NM_CONTROLLED=yes ONBOOT=yes PERSISTENT_DHCLIENT=yes TYPE=Ethernet USERCTL=no IPADDR0=172.27.0.10 IPADDR1=172.27.0.11 IPADDR2=172.27.0.12 IPADDR3=172.27.0.13 IPADDR4=172.27.0.14 IPADDR5=172.27.0.15 IPADDR6=172.27.0.16 IPADDR7=172.27.0.17 IPADDR8=172.27.0.18 IPADDR9=172.27.0.19 NETMASK=255.255.0.0 GATEWAY=172.27.0.1 DNS1=183.60.83.19 DNS2=183

Linux rp_filter配置引起的组播断流问题

痴心易碎 提交于 2019-11-29 00:58:04
引子   前一段时间处理一个线上问题,服务器拉组播码流,但是每隔3-4分钟就断流一次,引起服务异常。排除了交换机和组播网络的问题后, 确认问题还是在服务器侧。 组播为什么断流?   前方工程人员抓包确认,交换机发送了igmp general query报文,但是服务器没有响应组播report报文,交换机上igmp条目超时退出,导致断流。   抓包分析如下:    rp_filter配置对入向报文的影响   具体的排查过程就不再赘述了,这里只写结论:rp_filter配置影响了系统响应IGMP general query查询,当rp_filter设置为0后, 系统正常响应交换机GIMP general query报文,组播码流没有再出现断流。   即使系统中配置了策略路由,也没有发挥应有的作用,rp_filter模块在做反向路径检查时,还是认为源地址校验失败。这比较 令人费解,看了只能从rp_filter机制和内核代码中找答案了。 rp_filter简要说明   关于rp_filter详细描述,可以参考Lninux内核Documentation\networking\ip-sysctl.txt描述,以及本文末尾的博文链接。      rp_filter - INTEGER     0 - No source validation.     1 - Strict mode as

第十四周作业

江枫思渺然 提交于 2019-11-28 20:44:04
1、 LVS实现nat,dr NAT模式 ``` 1.临时开启转发,(写入内存,在内存中开启) echo "1" > /proc/sys/net/ipv4/ip_forward 2.永久开启转发,(写入内核) 在 vim /etc/sysctl.conf 下 加入此行 net.ipv4.ip_forward = 1 ~lvs]# echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf 开启forward转发功能 ~lvs]# sysctl –p 重载 ~lvs]# sysctl –a | grep ip_f 查看状态 ~web27]# echo rs27 > index.html ~web17]# echo rs17 > index.html ~lvs]# yum –y install ipvsadm ~lvs]# ipvsadm –A –t 172.20.0.200:80 –s rr ~lvs]# ipvsadm –Ln 查看状态(注意,ipvsadm -Ln顺序不要变更!!与iptables –vnl的顺序是不一样的) ~lvs]# ipvsadm –a –t 172.20.0.200:80 –r 192.168.30.17 -m ~lvs]# ipvsadm –a –t 172.20.0.200:80 –r 192.168.30.27

Configure git to use IPv4 instead of IPv6 by default

一笑奈何 提交于 2019-11-28 20:18:40
Checking the environment variables and also HTTP configuration options does not reveal something. Is there a way to do this? With git 2.8 (March 2016), you can force git fetc h/ push / clone to use IPV4 or IPV6. (for git pull , see below Git 2.16, Q1 2018) See commit c915f11 (03 Feb 2016) by Eric Wong ( ele828 ) . (Merged by Junio C Hamano -- gitster -- in commit e84d5e9 , 24 Feb 2016) connect & http : support -4 and -6 switches for remote operations Sometimes it is necessary to force IPv4-only or IPv6-only operation on networks where name lookups may return a non-routable address and stall

firewall-cmd命令的富语言(richlanguage)示例

最后都变了- 提交于 2019-11-28 17:42:13
一、为协议“ah”启用新的IPv4和IPv6连接   firewall-cmd --permanent --add-rich-rule 'rule protocol value="ah" accept' 二、允许新的IPv4和IPv6连接服务ftp和log 1每分钟使用审计   firewall-cmd --permanent --add-rich-rule 'rule service name="ftp" log limit value="1/m" audit accept' 三、允许使用syslog从地址192.168.0.0/24为服务tftp和每分钟日志1提供新的IPv4连接   firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" source address="192.168.0.0/24" service name="tftp" log prefix="tftp" level="info" limit value="1/m" accept' 四、 新的IPv6连接从1:2:3:4:6::到服务半径都被拒绝,并以每分钟3次的速度记录。 接受来自其他源的新的IPv6连接。   firewall-cmd --permanent --add-rich-rule 'rule family="ipv6"

Linux优化

空扰寡人 提交于 2019-11-28 16:12:19
编辑如下配置文件 vim /etc/sysctl.conf 最后几行替换成 #see details in https://help.aliyun.com/knowledge_detail/41334.html kernel.sysrq = 1 net.ipv4.tcp_max_tw_buckets = 5000 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse=1 net.ipv4.tcp_tw_recycle=1 net.ipv4.tcp_fin_timeout=30 net.ipv4.tcp_keepalive_time=60 net.ipv4.tcp_keepalive_probes=5 net.core.netdev_max_backlog=3000 改完后保存,并执行下面命令让配置生效 /sbin/sysctl -p reboot 来源: https://blog.csdn.net/Huang_Y_hui/article/details/100085281

How do I choose a multicast address for my application's use?

别来无恙 提交于 2019-11-28 14:07:09
问题 How should I choose an IPv4 multicast address for my application's use? I may need more than one (a whole range perhaps ultimately) but just want to avoid conflicts with other applications. Packets will be entirely contained within an administrative domain, probably a LAN If several independent instances of my application are in use on the same network, they could each use their own multicast address - but if they don't, they will be able to coexist anyway, they'll just have a small amount of