我想使用python的子进程模块设置IP地址。
我试图像这样使用它:
from subprocess import call
call(["ifconfig", "eth0", "192.168.1.5", "netmask", "255.255.255.0", "broadcast", "192.168.2.255"])
当我在CentOS服务器上运行此脚本时,出现此错误:
SIOCGIFADDR: Cannot assign requested address
SIOCSIFBROADCAST: Cannot assign requested address
SIOCSIFBRDADDR: Cannot assign requested address
我无法弄清楚这个错误的来源。