开始之前先说明一下,EIP直通跟NAT网关冲突,需要配路由
通过CVM控制台的VNC登录到CVM
给主网卡配置静态外网IP、子网掩码(255.255.255.255)、网关(当前vpc的网关ip,一般是该网段第一个内网ip)以及默认的VPC DNS地址
请不要给主网卡配内网IP(不论是主网卡的内网IP还是辅助网卡的内网IP都不要配)
也请不要把主网卡的内网IP配给辅助网卡,必须确保辅助网卡上是辅助网卡的内网IP
e.g., after executing as follow
route delete 10.0.0.0/8
route -p add 10.0.0.0/8 $gwip IF $Eth1'sID
让内网网段10.0.0.0/8的流量走辅助网卡上辅助网卡的内网IP(非主网卡的内网IP)
route delete 100.64.0.0/10
route -p add 100.64.0.0/10 $gwip IF $Eth1'sID
让内网网段100.64.0.0/10的流量走辅助网卡上辅助网卡的内网IP(非主网卡的内网IP)
route delete 172.16.0.0/12
route -p add 172.16.0.0/12 $gwip IF $Eth1'sID
让内网网段172.16.0.0/12的流量走辅助网卡上辅助网卡的内网IP(非主网卡的内网IP)
route delete 192.168.0.0/16
route -p add 192.168.0.0/16 $gwip IF $Eth1'sID
让内网网段192.168.0.0/16的流量走辅助网卡上辅助网卡的内网IP(非主网卡的内网IP)
route delete 169.254.0.0
route -p add 169.254.0.0/16 $gwip IF $Eth1'sID
让内网网段169.254.0.0/16的流量走辅助网卡上辅助网卡的内网IP(非主网卡的内网IP)
route delete 183.60.83.19
route delete 183.60.82.98
route -p add 183.60.83.19 $gwip IF $Eth1'sID
route -p add 183.60.82.98 $gwip IF $Eth1'sID
让内网解析的流量走辅助网卡上辅助网卡的内网IP(非主网卡的内网IP)
route delete 255.255.255.255
route -p add 255.255.255.255 $gwip IF $Eth1'sID
让内网广播流量走辅助网卡上辅助网卡的内网IP(非主网卡的内网IP)
route delete 0.0.0.0/0
route -p add 0.0.0.0/0 $gwip IF $Eth0'sID
其他流量走主网卡上的外网IP
最后,把\"%conname_eth0%\"替换为主网卡名称用双引号引起来,然后把这2句存为.bat文件执行
for /f "tokens=2 delims=_" %%i in ('"getmac|findstr /i tcp"') do REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\%%i" /v DefaultGatewayMetric /t REG_MULTI_SZ /d "1\0" /f
netsh interface ip set interface interface=\"%conname_eth0%\" metric=1 2>nul 1>nul
①从控制台取消EIP直通后,把2个网卡在vnc里都手动设置dhcp获取网络
②执行route print查看主网卡interface号
route print|findstr /i "Tencent VirtIO Ethernet"
下面cmd代码里的%gwip%、%idx1%就是vpc网关IP和主网卡interface号,批量替换后在cmd命令行执行即可
http://windows-1251783334.cos.ap-shanghai.myqcloud.com/resume.txt
route delete 10.0.0.0/8 2>nul 1>nul
route -p add 10.0.0.0/8 %gwip% IF %idx1% 2>nul 1>nul
route delete 100.64.0.0/10 2>nul 1>nul
route -p add 100.64.0.0/10 %gwip% IF %idx1% 2>nul 1>nul
route delete 172.16.0.0/12 2>nul 1>nul
route -p add 172.16.0.0/12 %gwip% IF %idx1% 2>nul 1>nul
route delete 192.168.0.0 2>nul 1>nul
route -p add 192.168.0.0/16 %gwip% IF %idx1% 2>nul 1>nul
route delete 169.254.0.0 2>nul 1>nul
route -p add 169.254.0.0/16 %gwip% IF %idx1% 2>nul 1>nul
route delete 183.60.83.19 2>nul 1>nul
route delete 183.60.82.98 2>nul 1>nul
route -p add 183.60.83.19 %gwip% IF %idx1% 2>nul 1>nul
route -p add 183.60.82.98 %gwip% IF %idx1% 2>nul 1>nul
route delete 255.255.255.255 2>nul 1>nul
route -p add 255.255.255.255 %gwip% IF %idx1% 2>nul 1>nul
route delete 0.0.0.0/0 2>nul 1>nul
route -p add 0.0.0.0/0 %gwip% IF %idx1% 2>nul 1>nul
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。