6

I ran curl on curlmyip.com, and I got the wrong output ip address. My systemd service file is:

[Unit]
Description=Wired Networking
Wants=network.target dibbler-client.service
Before=network.target dibbler-client.service

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/24 dev ${interface}
ExecStart=/sbin/ip addr add ${failover}/32 dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway} src ${failover}
ExecStart=/sbin/ip -6 addr add ${addressv6}/64 dev ${interface}

ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip -6 addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down

[Install]
WantedBy=multi-user.target

And variables are:

interface=eno1
address=88.190.15.135
address6=2001:bc8:300a:dead::b12d
failover=212.83.129.104
broadcast=88.190.15.255
gateway=88.190.15.1

Now, ip addr give me:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether b8:ac:6f:94:e2:4e brd ff:ff:ff:ff:ff:ff
    inet 88.190.15.135/24 scope global eno1
       valid_lft forever preferred_lft forever
    inet 212.83.129.104/32 scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::baac:6fff:fe94:e24e/64 scope link
       valid_lft forever preferred_lft forever

and ip route:

default via 88.190.15.1 dev eno1  src 212.83.129.104
88.190.15.0/24 dev eno1  proto kernel  scope link  src 88.190.15.135

curlmyip.com tell me that the output ip address is 88.190.15.135. How can I change this output address and make it 212.83.129.104?

EDIT: tested to change the src of the route to the gateway... No changes.

Thanks!

1
  • Have you tried ip route add 88.190.15.1/32 dev eno1 src 212.83.129.104? What happens when you do, ip addr del 88.190.15.135/24 dev eno1? Sep 30, 2013 at 12:35

3 Answers 3

10

It appears your provider is playing some dirty tricks with IP routing. The second IP address you are using is on a completely different network. Your dedibox is on AS12322, while your other IP address is registered to Tiscali on AS12876. This seems to work because the involved service providers are making it work.

Anyway, most programs that can make network connections have an option that lets you specify the source IP address. For the curl command line, that option is --interface.

curl --interface 212.83.129.104 http://curlmyip.com/
3
  • curl --interface 212.83.129.104 curlmyip.com -> 88.190.15.135
    – Cubox
    Sep 29, 2013 at 16:37
  • 2
    Better have a talk with your provider, then. They really do seem to be doing some funky stuff with your IP routing. Sep 29, 2013 at 16:37
  • I don't see how the above implies they are doing funky stuff with routing. It seems to me that the provider simply has a route that says "212.83.129.104 goes to 88.190.15.135", so they route traffic to that IP via the 88.190.15.0/24 network. If he sources his packets from 212.83.129.104, as it is configured to do, then they will come back to him just fine, no tricks or funny business. Sep 29, 2013 at 21:13
2

From the configuration you've posted it looks like you are specifying 212.83.128.104 as the source for your default route:

default via 88.190.15.1 dev eno1  src 212.83.129.104

You should probably change that, or remove it.

EDIT: Apparently I misread the question and thought that 212.83.128.104 was being used as the source IP. If I re-read it correctly, 88.190.15.135 is actually being used as the source IP, and the desired behavior is to have 212.83.129.104 used instead. To diagnose, we'll need more information, but my guess is that you are being affected by this bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1093999 where ip route ... src is broken in the kernel.

5
  • Hum... There is no typo in thip ip address in every single conf file... I don't see what you want to say here...
    – Cubox
    Sep 29, 2013 at 10:59
  • ExecStart=/sbin/ip route add default via ${gateway} src ${failover} <-- now why exactly are you surprised that the failover-IP is used as source? Sep 29, 2013 at 11:48
  • I'm not saying there is a typo, I'm saying that it is doing EXACTLY what it is configured to do: use source IP of 212.83.129.104 when routing via the default route. If the question is "why is my traffic sourced from 212.83.129.104 instead of 88.190.15.135?", then the answer is "because it is configured that way, and your provider has a static route to send it back to you via 88.190.15.135". If you don't want it to do that, then change the configuration so it doesn't source from that IP. Sep 29, 2013 at 21:14
  • But... Did you read it? I want 212.83.129.104 as the source ip. Actually, it's 88.190.15.135 and I don't know why.
    – Cubox
    Sep 30, 2013 at 12:39
  • Apparently I misread it. I thought you were saying the opposite (which was reinforced by Karma's comment). I'll edit the answer appropriately. Sep 30, 2013 at 14:24
0

As my dedicated provider told me, https://twitter.com/online_fr/status/384662183751450624.

I added this: -t nat -A POSTROUTING -o eno1 \! -d 10.8.0.0/24 -j SNAT --to-source 212.83.129.104 and everything is now fine :)

If you are hosted by Online.net, it's the only way.

1
  • 1
    See, they were doing dirty tricks with their IP routing after all. Sep 30, 2013 at 14:44

You must log in to answer this question.

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