Effect of update-source command in BGP config on nexthop - bgp

In BGP protocol the nexthop attribute of the prefix advertised via BGP to an EBGP peer is set to the egress interface's IP address. Also, the source address of the BGP packet is also set to the ip address of the egress/outgoing interface.
Now, if I use the "update-source" command, will it just change the source address of the BGP packets Or will it also change the next-hop path attribute value ?

Related

Scapy not sending IPv6 packets with global scope destination address

I'm trying to send IPv6 packets with scapy. I don't really care what higher-level protocol is used, so I simply send:
send(IPv6(dst="2001:db9:1::4"))
I have a route toward that destination, running ip -6 route show I see:
2001:db9:1::4 dev vt0 metric 1024
If I send a ping request from the command line, I can see it in tcpdump in the destination device. But if I send the IPv6 packet with scapy, I get these messages, and I don't see anything in tcpdump:
WARNING: No route found for IPv6 destination 2001:db9:1::4 (no default route?)
WARNING: No route found for IPv6 destination 2001:db9:1::4 (no default route?)
WARNING: more No route found for IPv6 destination 2001:db9:1::4 (no default route?)
.
Sent 1 packets.
But it works if I use the link-local address of the destination device. I only get one warning message (similar to the first line in the messages above), and I see the packet in tcpdump.
Any idea why this happens, and how can I fix it?
The sending interface needs to have a global IPv6 address.
Packets with a global destination address must have a global source address as well, otherwise the packet won't be forwarded.

Does routing affect a socket with a bound source address?

Let's say I have two network interfaces:
eth0 with address 10.0.0.1
eth1 with address 192.168.0.1
Using route or ip route add I have set it to route:
All addresses to eth0
1.2.3.4 only to eth1
So packets to 1.2.3.4 should be routed to eth1, and everything else to eth0.
I then create a UDP socket and use bind() to set its local address to 192.168.0.1. Then I send a packet to 1.2.3.4.
Will it be be sent over eth1 per the routing table or eth0 because it is bound to that IP address? I tried, and it seems to be sent on eth1.
Is there a way I can force a socket to use eth0, which has a valid route to the destination, but not the most specific rule? I know about SO_BINDTODEVICE, but prefer to avoid using interface names in C code.
For sockets if you want the the Kernel and its routing table to pick the best interface for you using any available port you don't have to call bind() before sending datagram socket.
If you do bind a socket, it will be bound to a network device with that specific IP address. But does it make sense if packet can't reach destination address from that network device?

Two gateway routing issue

I have two NICs.
On eth1 IP is 10.135.28.86/16.
On eth IP is 135.251.8.43/24.
My routing table is like below:
135.251.8.0/24 dev eth1 proto kernel scope link src 135.251.8.43
10.135.0.0/16 dev eth0 proto kernel scope link src 10.135.28.86
169.254.0.0/16 dev eth0 scope link metric 1002
169.254.0.0/16 dev eth1 scope link metric 1003
10.0.0.0/8 via 10.135.0.1 dev eth0
default via 135.251.8.1 dev eth1
Now if I ping 10.135.28.86 from 10.34.7.103, it's OK, while if I ping 135.251.8.43 from 10.34.7.10, it fails.
And if I ping my public IP 135.251.8.43 from 135.252.11.7, it's OK, if I ping 10.135.28.86, it fails.
However, on my other machines which have exactly the same subnet and gateway configured, I can ping both IP either from 10.34.7.103 or 135.252.11.7.
Any ideas on this?
I used tcpdump to capture icmp packet on other machines and found that echo request come in eth0 and echo reply out from eth1.
but on this machine no echo reply were captured.
When you ping from your other machines with IP's in both networks the machine uses the interface on the same network to send the packet (so private-to-private and public-to-public, since they are on directly connected subnets). That is why it reaches, they are on the same subnet.
I see 2 scenarios.
1.
The machine which only has IP on your private network (10.34.7.10) probobly sends its ping to dgw (IP?) which then forwards it to 135.251.8.43 (eth0).
But since the source adress (10.34.7.10) is on a network directly connected to it's other interface (eth1) the answer will be sent back there. I would say you have a flawed network architecture.
The machine 10.34.7.10 has a static route for 135.251.8.43 to 10.135.28.86, but your machine has not bridged the 2 networks.

what is "internet protocol, pseudo protocol number"?

I am using raw socket to capture network packets. I captured Ethernet header and then I accessed IP header and in IP header, there is a field of 'protocol'. I printed this field and compare with values present in /etc/protocols. I have received '0' value that means-
ip 0 IP #'internet protocol, pseudo protocol number'
That means IP header contains protocol that is also IP. What does that mean ?
According to Protocol Numbers this is the protocol IPv6 Hop-by-Hop Option [RFC2460].

OpenSIPs stun module require two IP addresses

I have to make a STUN server in OpenSIPs, and it says that I need to bind 2 IP addresses.
http://www.opensips.org/About/News0042
A STUN server uses 2 ips and 2 ports to create 4 sockets on which to listen or respond.
STUN requires 2 routable ip addresses
How can I enable two public IP addresses into one Linux server? I've searched all website, and failed to find the answer.
Several options.
Option 1.
You likely just need to use ifconfig from the command line to start
You can assign an additional static IP address to your NIC via the command line. Type ifconfig to get the name of your default adapter. It's typically "eth0". Then do add a secondary address to this adapter, the command is something like the following:
sudo ifconfig eth0:1 inet up netmask 255.255.255.0 192.168.1.55
Where 255.255.255.0 is the netmask of my 8-bit subnet and 192.16.1.55 is an existing IP address that no other device on my subnet is already using.
Option 2.
After you get your server up and running with Option 1, you likely need to find a way to get the IP address assigned by "ifconfig" to persist after a reboot. You could likely stick an ifconfig statement into one of your rc.init files. But most Linux skus have a formal way of configuring an interface with another /etc file. But this step varies between different flavors of Linux. On Ubuntu, this is all defined in the /etc/network/interfaces file. Add these three lines to the bottom of your existing file:
iface eth0:1 inet static
address 192.168.1.55
netmask 255.255.255.0
Option 3 (shameless plug)
Switch to Stuntman ( www.stunprotocol.org ) as your STUN server. Its default mode only requires one IP address to be present on the box. Most client usages of the STUN protocol don't require the second IP address unless to do NAT classification and behavior tests.

Resources