Routing configuration to forward multicast traffic to a single NIC on RedHat 6 - linux

I'm trying to edit /etc/sysconfig/network-scripts/route-eth0 to make all multicast packets sent to device eth0 on RedHat 6.3, following this guide.
I tried writing like:
224.0.0.0/4 dev eth0
but it never works....
How can I specify multicast routing on this file?

I think you should add route in /etc/sysconfig/static-routes
One more alternative solution to save permanent route is add your route command in following file.
/etc/rc.local
More option to look.
also Enable MC routing in kernel
sysctl -w net.ipv4.conf.all.mc_forwarding=0
Make sure you have MC routing support in kernel. for example.
# cat /boot/config-`uname -r` | grep IP_MROUTE
CONFIG_IP_MROUTE=y
Netstat also tell you whether it enable or not
netstat -g

Related

Is it possible to run command "route -n" specifically for a NIC

I am fairly new to linux I wanted to ask if its possible in linux commands to run a "route -n" command to retrieve information for a specific NIC. E.G route -n ether0. Because currently it shows me for all the NIC's but what if I want just for one?
Use the iproute2 ip command (rather than the antique route command), and provide a selector with your NIC:
# for ether0
ip -o route list dev ether0
(I've added -o since your tags indicate that you're using this for scripting purposes; ensuring that each result lives on its own line is appropriate in this case).
This is a significant improvement on the simple route | grep ether0 approach, as it shows routing entries which can end up sending traffic through a NIC but don't name that NIC explicitly.
As the default for iproute2 is to avoid leaning on the resolver, no local flag equivalent to -n is necessary; instead, if you did want to use the resolver, you would need to add -r.
Do you want see route for ether0, you can use below command
ip -o route show dev ether0
or
ip route show | grep ether0
or
route -n | grep ether0
or
netstat -nr | grep ether0
To see NIC for ether0, you can use ifconfig command and Gateway NIC you can use arp -a commands
ifconfig ether0
for see GW and direct connected NICS you can use below command
arp -a

What is the jessie/systemd equivalent to these two wheezy/sysvinit commands?

# Add a getty on the virtio console
echo 'V0:23:respawn:/sbin/getty 115200 hvc0' | sudo tee -a wheezy/etc/inittab
# Automatically bring up eth0 using DHCP
printf '\nauto eth0\niface eth0 inet dhcp\n' | sudo tee -a wheezy/etc/network/interfaces
These come from a description (https://blog.nelhage.com/2013/12/lightweight-linux-kernel-development-with-kvm/) of getting a small debian virtual machine running. The base vm image is being touched up after generating with debootstrap, specifically the 'wheezy' path is the result of
debootstrap --include=openssh-server wheezy wheezy
Post-systemd, /etc/inittab and /etc/network/interfaces aren't used anymore. What commands would have equivalent functionality? Note that at this point in the setup we only have filesystem access - we don't have a running guest yet, so there is no running systemd to talk to.

Scanning the network for all the hostnames present with their respective ip addresses

I have tried nmap, nbtscan, fping, arp-scan for the overstated need and all are producing expected output.
But I am facing some trouble with the arp command its not working and showing something like this:
? (10.240.253.2) at 80:a1:d7:7c:22:94 [ether] on eth0
<something>.local (10.240.253.53) at 9c:2a:70:d8:50:ed [ether] on eth0
I have tried arp -a and arp -a -n both. Also I tried running ping -b <broadcast ip address> before these command but ping -b does not execute at all means it does nothing.
On other systems in my network it is running fine. But it seems there is some setting problem with my computer that I am not aware of.
arp is not a scanner. It queries your system's ARP cache.
Therefore, it will only show IP and MAC addresses of hosts which have sent ARP queries or answers recently seen by your system.
As you mention, nmap, for example, is much more suited to what you're trying to do than arp.

Linux send URL my IP address on startup

So, I'm trying to write a simple bash script to send my internal IP address to a website of mine on startup. I am on a network with DHCP, so I don't always know what the IP address of my Raspberry Pi will be after I do a reboot over ssh. I figured I could fix this by sending my website the current IP on startup. I haven't written many bash scripts, and I'm not really sure how to send data to my website. Right now I was just trying in the terminal this:
wget -qO- http://http://mywebsite.com/private/CurrentIP.php?send=$(/sbin/ifconfig eth0|grep 'inet addr:')
But I'm not having any luck. I don't actually know much about linux, and I'm trying to learn. That's why I got the raspberry pi actually. Anyway, can someone head me in the right direction?
I already know I need to put it in /etc/init.d/.
You could do this:
IP_ADDR=$(ifconfig eth0 | sed -rn 's/^.*inet addr:(([0-9]+\.){3}[0-9]+).*$/\1/p')
wget -q -O /dev/null http://mywebsite.com/private/CurrentIP.php?send=${IP_ADDR}
...but if your machine is stuck behind NAT, $IP_ADDR won't be your externally-visible address. Might want to use $_SERVER['REMOTE_ADDR'] in your PHP instead of/in addition to this to get the address for your client that your server sees.
Edit: Sounds like you want to be able to find your Raspberry Pi on your local (DHCP-managed) network after reboots. Have you considered using Multicast DNS instead?
How it works in practice: Let's say you've set the hostname of your RasPi to gooseberry. If you've enabled a multicast DNS server on that machine, other computers on the same network segment that can send multicast DNS queries will be able to find it at the domain name gooseberry.local. This is a peer-to-peer protocol and not dependent on gooseberry receiving any specific address via DHCP - so if it reboots and receives a new address, other machines should still be able to find it.
Mac OS X has this enabled out of the box; this can be enabled on most Linux distros (on Debian/Ubuntu you'd install the avahi-daemon and libnss-mdns packages); not sure about Windows, but a quick Google shows encouraging results.
This worked for me (wget part untested, but it finds IP address):
interface="eth0"
ip_addr=$(ifconfig ${interface} | sed -rn 's/^.*inet *([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}).*$/\1/p')
wget -q -O /dev/null http://mywebsite.com/private/CurrentIP.php?send=${ip_addr}
Can't you use:
hostname --ip-address

Persist ifconfig lo multicast across reboots on Linux RHEL 6

Is there a way to persist the following command across reboots on Linux RHEL 6 (other than perhaps creating an init.d script):
ifconfig lo multicast
I have an application that requires multicast on 127.0.0.1, and I was wondering whether there's something in /etc/sysconfig/network-scripts that can help persist the ifconfig lo multicast across reboots.
Thanks in advance.
Thanks for the /etc/rc.local suggestion; it would work, and it's technically not an init.d script, so in my humble opinion, the -1 is a bit unfair. However, I'd like to avoid that route if possible in order to improve the maintenance of the file.
After some digging around, I couldn't find any files in the /etc/sysconfig/network-scripts/ that could help; however, I did find a potential solution; after tracing the ifup scripts, there's a hook to invoke an ifup-${DEVICE} file; since that doesn't exist for lo, I've created an ifup-lo file with 755 permissions as follows:
/etc/sysconfig/network-scripts/ifup-lo
# ifconfig is deprecated; use ip link instead...
/sbin/ip link set lo multicast on
/sbin/ip link set lo up
This will be invoked by the os when ifup lo is called, allowing any custom hooks to be added.
Any better solutions are appreciated.
The ideal solution would be for Redhat to add a MULTICAST=on or MULTICAST=off variable in the /etc/ifcfg-lo , but since that's not currently in place, ifup-lo will do for now...
append ifconfig lo multicast to the end of /etc/rc.local

Resources