RTNETLINK answers: Invalid argument, MPLS on mininet - linux

I am trying to apply MPLS on mininet and I was able to install iproute2, the problem that I have is when I try to use any command in the format
ip -f mpls xxx
I always get an error.
I was able to inser a route
mininet> r1 ip route add 10.0.4.0/24 encap mpls 400 via inet 172.16.1.2
mininet> r1 ip route show
10.0.1.0/24 dev r1-eth0 proto kernel scope link src 10.0.1.1
10.0.4.0/24 encap mpls 400 via 172.16.1.2 dev r1-eth1
172.16.1.0/24 dev r1-eth1 proto kernel scope link src 172.16.1.1
but I am not able to see it using the correct command for mpls
mininet> r1 ip -f mpls route show
mininet>
also when I try to do a swap of the labels I get an error
mininet> r5 ip -f mpls route add 400 as 405 via inet 172.16.8.2
RTNETLINK answers: Invalid argument
any help will be greatly appreciated.
UPDATE
I solved my problem by changing the value on /proc/sys/net/mpls/platform_labels the value set here will be the highest label value that can be used

I solved my problem by changing the value on /proc/sys/net/mpls/platform_labels the value set here will be the highest label value that can be used
But keep in mind that I have to set this value for all the devices on my mininet network as well as loading the mpls module and any parameter
* modprobe mpls_router
* modprobe mpls_gso
* modprobe mpls_iptunnel
* sysctl -w net.mpls.platform_labels=1048575
* sysctl -w net.mpls.conf.*-eth#.input=1 #for every interface that speaks mpls
I thought that doing it in it kernel will activate it for all, but apparently it has to be done within every device on the network

Related

Remove DNS from device using `nmcli`

I want to remove the DNS currently associated to the device and add a new one using nmcli
So, if I do nmcli device show eth0 I can see
IP4.DNS[1]: 10.0.2.2
If I do sudo nmcli device modify eth0 ipv4.dns "8.8.8.8"
then I can see
IP4.DNS[1]: 10.0.2.2
IP4.DNS[2]: 8.8.8.8
but I want to remove the first one. How can I do it? If i try sudo nmcli device modify eth0 ipv4.dns "" then the second one (8.8.8.8) is removed but the first one is still there.
My final goal is to set ONLY 8.8.8.8 (for example...)
EDIT:
I am a bit confused between connection and device.
For example, let's say that I had 10.0.2,2 and I had 8.8.8.8 using one of these two commands:
nmcli connection modify netplan-eth0 ipv4.dns 8.8.8.8
nmcli device modify eth0 ipv4.dns 8.8.8.8
Because it seems there is a device and then there is a connection bound to it, so I can modify the dns using one of these two commands.
Now, I can see:
Using nmcli device show I have in the result
IP4.DNS[1]: 10.0.2.2
IP4.DNS[2]: 8.8.8.8
but using nmcli connection show netplan-eth0 I can see only
ipv4.dns: 8.8.8.8
So, my problem now is that I can easily modify the only dns in the connection, that is 8.8.8.8 using one of the followin command:
nmcli connection modify netplan-eth0 -ipv4.dns 8.8.8.8
nmcli device modify eth0 -ipv4.dns 8.8.8.8
BUT, I don't know how to remove the 10.0.2.2 that is showing only in the device but not in the connection.
BTW I did not set manually 10.0.2.2, I suppose it was taken through dhcp. And for some motivation this dns is bound only to the device but not to the connection.
With these details the problem should be more clear :)
For the general way to modify the dns, look at the answer of missconfigured.
About the problem of the dns get through netplan or dhcp, I could remove them using the following command:
nmcli device modify eth0 ipv4.ignore-auto-dns yes
After that, I was able to remove the 10.0.2.2 dns.
To the Answer,
The below command is able to remove the default DNS, but after restart NetworkManager, the default DNS comes back. How to make it permanent? Thanks.
nmcli device modify eth0 ipv4.ignore-auto-dns yes

check whether eth0 is up while my active connection is ppp0

I've my eth0connection and I've a ppp0 connection.
keeping alive my ppp0 connection, can I test eth0 connection?
like checking
ping <ip> <eth0 connection>
Have you tried the following (Copying from different question that uses your issue unix.stackexchange)?:
If you look at ping manual man ping, you can read:
-I interface address
Set source address to specified interface address. Argument may be numeric IP
address or name of device.
So try, e.g.:
ping -I eth0 google.com

linux ip routing with multiple uplinks SINGLE interface

trying to setup a Proxmox machine that is running 3 vms. it has 3 public ips but these ips are on a single interface (eth0).
the 3 vms are on a bridge (vmbr0) with an address of 172.16.0.1/24
I have enable ip masquerading and forwarding. but I cannot figure out how to make each of the 3 vms (172.16.0.2, 172.16.0.3, 172.16.0.4) route out through a specific one of the public ips.
I have tried the standard iproute with 3 tables setting the gateways and rules but no matter what rule i set the vms still route out through the primary ip.
trouble is the 3 public ips are on complete seperate networks so they each have a different gateway. I know how to use iproute to do this if each public ip was on a seperate physical interface but this machine has all 3 on a single interface and iproute doesn't seem to like that because if I do ip route add default via 23.92.26.1 dev eth0:2 table node2 and then later list everything it shows via eth0. so aparently iproute doesn't like psuedo interfaces. I don't know a lot about iptables and I'm sure theres a way to do this with pure iptables but haven't found anything. all my google searches come up with iproute tables wich like i said don't seem to work with a signle interface.
Thank you in advance
considering ProxMox is running Debian try adding something like the following to your /etc/network/interfaces for each of the extra links
post-up route add -net <network identifier> netmask <netmask> gw <links gateway>
pre-down route del -net <network identifier> netmask <netmask> gw <links gateway>
and then with iptables if you want 172.16.0.2 to go through the second ip do like the following: (this is called Source NAT or SNAT) the --to-source specifies what ip you want the outgoing connections remapped to.
iptables -t nat -A POSTROUTING -s 172.16.0.2/24 -j SNAT --to-source <ip address you want it to go out of>
if you want all incoming connections on the same ip to go to 172.16.0.2 then you would also add the following (this is called Destination NAT or DNAT)
iptables -t nat -A PREROUTING -d <ip/mask bit> -j DNAT --to-destination 172.16.0.2
Question:
(1)3VM - 172.16.0.2, 172.16.0.3, 172.16.0.4
(2)Gateway - 172.16.0.1/24
(3)3 publicIP: $IP_A(gateway $IP_A_G), $IP_B(gateway $IP_B_G), $IP_C(gateway $IP_C_G)
(4)Your aim is every VM use the different public IP to visit outsite , suck as:
VM1(172.16.0.2) ----> $IP_A
VM2(172.16.0.3) ----> $IP_B
VM3(172.16.0.4) ----> $IP_C
So , I think you can use ip route to do this:
(1)In Promox(172.16.0.1)
echo "200 IPA" >> /etc/iproute2/rt_tables
echo "201 IPB" >> /etc/iproute2/rt_tables
echo "202 IPC" >> /etc/iproute2/rt_tables
Reboot Promox once .
(2)Create router
ip route del default table IPA
ip route add default via $IP_A_G table IPA
ip route del default table IPB
ip route add default via $IP_B_G table IPB
ip route del default table IPC
ip route add default via $IP_C_G table IPC
(3)Add route for each VM
ip rule add from 172.16.0.2 lookup IPA pref 200
ip rule add from 172.16.0.3 lookup IPB pref 201
ip rule add from 172.16.0.4 lookup IPC pref 202
ip route flush cache
DONE

iproute2 commands for MPLS configuration

Trying to figure out how one can use iproute2 to manage static label-switched MPLS routes in Linux kernel 4.1.
I am aware iproute2 support for MPLS might be incomplete right now [2].
Can anyone please shed some light on what iproute2-4.1.1 is currently able to do?
This is what I have found so far:
Documentation/networking/mpls-sysctl.txt
/proc/sys/net/mpls/platform_labels
/proc/sys/net/mpls/conf//input
Load mpls module
sudo modprobe mpls_router
Find sysctl support
sysctl -a --pattern mpls
net.mpls.conf.eth0.input = 0
net.mpls.conf.eth1.input = 0
net.mpls.conf.lo.input = 0
net.mpls.platform_labels = 0
Enable mpls support
sudo sysctl -w net.mpls.conf.eth0.input=1
sudo sysctl -w net.mpls.conf.eth1.input=1
sudo sysctl -w net.mpls.platform_labels=1000
push??? (how to add prefix-to-push action?)
sudo ip route add 1.1.1.1/32 via mpls 100/200/300 dev eth0
swap??? (how to add label-swap action?)
sudo ip -f mpls route add 10 via mpls 100/200/300 dev eth0
pop??? (how to add label-pop action?)
???
show??? (how to display label-switched routes?)
???
Can someone help me out .
Thanks in Advance.
A little bit too late, but hope it helps somebody. You can find them here:
Routing 10.10.10.10/32 to 192.168.1.2 with label 100:
ip route add 10.10.10.10/32 encap mpls 100 via inet 192.168.1.2
Label swapping 100 for 200 and sent to 192.168.2.2:
ip -f mpls route add 100 as 200 via inet 192.168.2.2
Decapsulating label 300 and delivering locally:
ip -f mpls route add 300 dev lo
To show MPLS routes you can do:
ip -f mpls route show
If your iproute2 version doesn't support those commands, you can get it from here:
https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-4.6.0.tar.gz
And then
./configure && make && make install

Isolated test network on a Linux server running a web server (lightttpd) and (curl) clients

I'm writing a testing tool that requires known traffic to be captured from a NIC (using libpcap), then fed into the application we are trying to test.
What I'm attempting to set-up is a web server (in this case, lighttpd) and a client (curl) running on the same machine, on an isolated test network. A script will drive the entire setup, and the goal is to be able to specify a number of clients as well as a set of files for each client to download from the web server.
My initial approach was to simply use the loopback (lo) interface... run the web server on 127.0.0.1, have the clients fetch their files from http://127.0.0.1, and run my libpcap-based tool on the lo interface. This works ok, apart from the fact that the loopback interface doesn't emulate a real Ethernet interface. The main problem with that is that packets are all inconsistent sizes... 32kbytes and bigger, and somewhat random... it's also not possible to lower the MTU on lo (well, you can, but it has no effect!).
I also tried running it on my real interface (eth0), but since it's an internal web client talking to an internal web server, traffic never leaves the interface, so libpcap never sees it.
So then I turned to tun/tap. I used socat to bind two tun interfaces together with a tcp connection, so in effect, i had:
10.0.1.1/24 <-> tun0 <-socat-> tcp connection <-socat-> tun1 <-> 10.0.2.1/24
This seems like a really neat solution... tun/tap devices emulate real Ethernet devices, so i can run my web server on tun0 (10.0.1.1) and my capture tool on tun0, and bind my clients to tun1 (10.0.2.1)... I can even use tc to apply shaping rules to this traffic and create a virtual WAN inside my linux box... but it just doesn't work...
Here are the socat commands I used:
$ socat -d TCP-LISTEN:11443,reuseaddr TUN:10.0.1.1/24,up &
$ socat TCP:127.0.0.1:11443 TUN:10.0.2.1/24,up &
Which produces 2 tun interfaces (tun0 and tun1), with their respective IP addresses.
If I run ping -I tun1 10.0.1.1, there is no response, but when i tcpdump -n -i tun0, i see the ICMP echo requests making it to the other side, just no sign of the response coming back.
# tcpdump -i tun0 -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun0, link-type RAW (Raw IP), capture size 65535 bytes
16:49:16.772718 IP 10.0.2.1 > 10.0.1.1: ICMP echo request, id 4062, seq 5, length 64
<--- insert sound of crickets here (chirp, chirp)
So am I missing something obvious or is this the wrong approach? Is there something else i can try (e.g. 2 physical interfaces, eth0 and eth1???).
The easiest way is just to use 2 machines, but I want all of this self-contained, so it can all be scripted and automated on a single machine, without and other dependencies...
UPDATE:
There is no need for the 2 socats to be connected with a tcp connection, it's possible (and preferable for me) to do this:
socat TUN:10.0.1.1/24,up TUN:10.0.2.1/24,up &
The same problem still exists though...
OK, so I found a solution using Linux network namespaces (netns). There is a helpful article about how to use it here: http://code.google.com/p/coreemu/wiki/Namespaces
This is what I did for my setup....
First, download and install CORE: http://cs.itd.nrl.navy.mil/work/core/index.php
Next, run this script:
#!/bin/sh
core-cleanup.sh > /dev/null 2>&1
ip link set vbridge down > /dev/null 2>&1
brctl delbr vbridge > /dev/null 2>&1
# create a server node namespace container - node 0
vnoded -c /tmp/n0.ctl -l /tmp/n0.log -p /tmp/n0.pid > /dev/null
# create a virtual Ethernet (veth) pair, installing one end into node 0
ip link add name veth0 type veth peer name n0.0
ip link set n0.0 netns `cat /tmp/n0.pid`
vcmd -c /tmp/n0.ctl -- ip link set n0.0 name eth0
vcmd -c /tmp/n0.ctl -- ifconfig eth0 10.0.0.1/24 up
# start web server on node 0
vcmd -I -c /tmp/n0.ctl -- lighttpd -f /etc/lighttpd/lighttpd.conf
# create client node namespace container - node 1
vnoded -c /tmp/n1.ctl -l /tmp/n1.log -p /tmp/n1.pid > /dev/null
# create a virtual Ethernet (veth) pair, installing one end into node 1
ip link add name veth1 type veth peer name n1.0
ip link set n1.0 netns `cat /tmp/n1.pid`
vcmd -c /tmp/n1.ctl -- ip link set n1.0 name eth0
vcmd -c /tmp/n1.ctl -- ifconfig eth0 10.0.0.2/24 up
# bridge together nodes using the other end of each veth pair
brctl addbr vbridge
brctl setfd vbridge 0
brctl addif vbridge veth0
brctl addif vbridge veth1
ip link set veth0 up
ip link set veth1 up
ip link set vbridge up
This basically sets up 2 virtual/isolated/name-spaced networks on your Linux host, in this case, node 0 and node 1. A web server is started on node 0.
All you need to do now is run curl on node 1:
vcmd -c /tmp/n1.ctl -- curl --output /dev/null http://10.0.0.1
And monitor the traffic with tcpdump:
tcpdump -s 1514 -i veth0 -n
This seems to work quite well... still experimenting, but looks like it will solve my problem.

Resources