I want to create a crawler using python which works with multiple ip, so I need a vm with multiple ips.
I send requests using python as below:
import requests
from requests_toolbelt.adapters import source
def send_request():
session = requests.session()
new_source = source.SourceAddressAdapter('5.34.201.22')
session.mount('http://', new_source)
session.mount('https://', new_source)
response = session.get('https://example.com/')
I am using ubuntu server 22.04 and have 4 interfaces and I want to change netplan
configuration to have 4 static ips.
I used ip route show
command to find gateway of these interfaces.
default via 5.34.200.1 dev eth2 proto static
default via 188.121.116.1 dev eth1 proto static
default via 5.34.200.1 dev eth0 proto static
default via 188.121.116.1 dev eth0 proto static
default via 188.121.116.1 dev eth3 proto dhcp src 188.121.119.142 metric 100
5.34.200.0/22 dev eth2 proto kernel scope link src 5.34.201.218
5.34.200.0/22 dev eth0 proto kernel scope link src 5.34.201.22
169.254.169.254 via 188.121.116.10 dev eth3 proto dhcp src 188.121.119.142 metric 100
188.121.116.0/22 dev eth1 proto kernel scope link src 188.121.116.94
188.121.116.0/22 dev eth0 proto kernel scope link src 188.121.116.94
188.121.116.0/22 dev eth3 proto kernel scope link src 188.121.119.142 metric 100
188.121.116.1 dev eth3 proto dhcp scope link src 188.121.119.142 metric 100
188.121.116.10 dev eth3 proto dhcp scope link src 188.121.119.142 metric 100
I changed netplan
configuration file /etc/netplan/50-cloud-init.yaml
as below:
network:
version: 2
ethernets:
eth0:
addresses:
- 5.34.201.22/22
- 5.34.201.218/22
nameservers:
addresses:
- 8.8.8.8
routes:
- to: default
via: 5.34.200.1
eth1:
addresses:
- 188.121.116.94/22
- 188.121.119.142/22
nameservers:
addresses:
- 8.8.8.8
routes:
- to: default
via: 188.121.116.1
I tested ips with mtr
command like this.
mtr -a 5.34.201.22 example.com
but it did not connect.
update
also tried this.
network:
version: 2
ethernets:
eth0:
addresses:
- 5.34.201.22/22
nameservers:
addresses:
- 8.8.8.8
routes:
- to: default
via: 5.34.200.1
eth1:
addresses:
- 188.121.116.94/22
nameservers:
addresses:
- 8.8.8.8
routes:
- to: default
via: 188.121.116.1
eth2:
addresses:
- 5.34.201.218/22
nameservers:
addresses:
- 8.8.8.8
routes:
- to: default
via: 5.34.200.1
eth3:
addresses:
- 188.121.119.142/22
nameservers:
addresses:
- 8.8.8.8
routes:
- to: default
via: 188.121.116.1
but it did not work.