0

Straightforwardly, I've two inet devices: enp0s3 and enp0s9.

enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:f3:bf:35 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 82336sec preferred_lft 82336sec
    inet6 fe80::67c3:35fd:6d5c:19f8/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:13:5d:97 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.240/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s9
       valid_lft 2998sec preferred_lft 2998sec
    inet6 fe80::9a68:d4d0:6bf7:485d/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

Some services I need to reach are only accessible under 10.49.0.0/16 via proxy (10.49.1.1:8080). This range is accessible using enp0s3 inet device.

As you can see bellow:

   ~ ping 10.49.99.166 -I enp0s3
PING 10.49.99.166 (10.49.99.166) from 10.0.2.15 enp0s3: 56(84) bytes of data.
64 bytes from 10.49.99.166: icmp_seq=1 ttl=250 time=15.3 ms
64 bytes from 10.49.99.166: icmp_seq=2 ttl=250 time=14.1 ms
64 bytes from 10.49.99.166: icmp_seq=3 ttl=250 time=11.8 ms
^C
--- 10.49.99.166 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2008ms
rtt min/avg/max/mdev = 11.789/13.725/15.287/1.452 ms
   ~ ping 10.49.99.166 -I enp0s9
PING 10.49.99.166 (10.49.99.166) from 192.168.1.240 enp0s9: 56(84) bytes of data.
^C
--- 10.49.99.166 ping statistics ---
7 packets transmitted, 0 received, 100% packet loss, time 6093ms
   ~

What I want to get is that everything sent to 10.49.0.0/16 goes via enp0s3 inet device.

I've tried to add this route using this command:

sudo ip route add 10.49.0.0/16 via 10.0.2.15 dev enp0s3

So,

   ~ ip route show
default via 192.168.1.1 dev enp0s9 proto dhcp src 192.168.1.240 metric 100
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 20101
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 101
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.18.0.0/16 dev br-34c76a82552a proto kernel scope link src 172.18.0.1 linkdown
192.168.1.0/24 dev enp0s9 proto kernel scope link src 192.168.1.240 metric 100

After that, I've tested rule:

   ~ ip route get 10.49.99.166
10.49.99.166 dev enp0s3 src 10.0.2.15 uid 1000
    cache

However, when I'm trying to get access to my desired services, always I'm getting something like is not able to reach it:

   ~ oc login --token=... --server=https://domain:6443
error: dial tcp 10.49.99.166:6443: connect: no route to host - verify you have provided the correct host and port and that the server is currently running.

   ~ telnet api.ocpdes.t-systems.es 6443
Trying 10.49.99.166...
telnet: Unable to connect to remote host: No route to host

Any ideas?

1
  • maybe pretty print the route table: ip route show | sed -e "s/default via /def:/" -e "s/ dhcp /&- - /" | column -t # adjust the sed if needed, to have better columns Jan 25 at 14:46

1 Answer 1

1

sudo ip route add 10.49.0.0/16 via 10.0.2.15 dev enp0s3

10.0.2.15 appears to be the IP address associated with enp0s3. You should be providing the address of the router on 10.0.2.0/24 which can forward the packets. Probably 10.0.2.2 but check with whoever manages the network.

NB changing / adding routes alone is not sufficient to access services behind a proxy.

BTW: You currently have 2 default routes set - thats OK as they have different metrics - but that may cause some pain in future.

4
  • It's working now using 10.0.2.2 (sudo ip route add 10.49.0.0/16 via 10.0.2.2 dev enp0s3). How did you know I need it instead of 10.0.2.15)? According to get access to services behind proxies... Do you mean setting environment varaibles (HTTPS_PROXY, HTTP_PROXY...), or are you thinking in some other stuff? Do you suggest me to delete one default? Which one? Lot of questions... sorry
    – Jordi
    Jan 25 at 13:26
  • You just need to be on the same subnet as the router and proxy. But since the router is 10.0.2.0, it will probably assign 10.0.2.2, since it's the first available in that subnet.
    – Brian
    Jan 25 at 13:50
  • Actually, 10.2.0.1 is the first usable host address in the range - I got 10.0.2.2 from your existing default route (not used due to lower metric)
    – symcbean
    Jan 25 at 14:12
  • ...and yes - you need a client which understands proxies and they need some sort of configuration. Most CLI tools use lower case names for the env vars.
    – symcbean
    Jan 25 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .