Tag Info

Hot answers tagged

23

Just to make sure we're on the same page (your question is ambiguous this way), asking to bind TCP on port 0 indicates a request to dynamically generate an unused port number. In other words, the port number you're actually listening on after that request is not zero. There's a comment about this in [linux kernel source]/net/ipv4/inet_connection_sock.c on ...


22

In the simplest terms, a socket is a pseudo-file that represents a network connection. Once a socket has been created (using the proper primitives, and the proper parameters to identify the other host), writes to the socket are turned into network packets that get sent out, and data received from the network can be read from the socket. In one regard, ...


21

The limit on "open files" is not really just for files. It's a limit on the number of kernel handles a single process can use at one time. Historically, the only thing that programs would typically open a lot of were files, so this became known as a limit on the number of open files. There is a limit to help prevent processes from say, opening a lot of files ...


18

Setting up a dummy interface If you want to create network interfaces, but lack a physical NIC to back it, you can use the dummy link type. You can read more about them here: iproute2 Wikipedia page. Creating eth10 To make this interface you'd first need to make sure that you have the dummy kernel module loaded. You can do this like so: $ sudo lsmod | ...


15

You're complicating your life needlessly. Use scp. To transfer a file myfile from your local directory to directory /foo/bar on machine otherhost as user user, here's the syntax: scp myfile user@otherhost:/foo/bar. EDIT: It is worth noting that transfer via scp/SSH is encrypted while transfer via netcat or HTTP isn't. So if you are transferring sensitive ...


13

This is one of those things that surprises people because it goes against what they've been taught. 2 machines with the same hardware mac address on the same broadcast domain can talk to each other just fine as long as they have different IP addresses (and the switching gear plays nice). Lets start with a test setup: VM1 $ ip addr show dev enp0s8 3: ...


12

The reason why TCP/IP sockets use file descriptors is that, when the sockets interface was first designed and implemented (in BSD Unix, in 1983), its designers felt that a network connection was analogous to a file - you can read, write, and close both, and that it would fit well with the Unix idea of "everything is a file". Other TCP/IP network stack ...


11

This is easy enough to measure, at least if you nmap a host your machine is not otherwise communicating with. Just use tcpdump or wireshark to capture the traffic, limited to that IP address. You could also use iptables counters, etc. I did so (using wireshark), the machine I tested on has fewer open TCP ports (5), but the totals were 2009 packets, 118,474 ...


10

In a screen or tmux session, set up a shell that will reverse your changes after a delay. I don't know anything about iptables, so can't help with that, but something like this has saved my proverbial bacon on numerous occasions while altering live firewall configs on FreeBSD: # In one `screen` or `tmux` window % sleep 60 && <command to reverse ...


10

And surely any attacker who could alter the file for malicious purposes could likewise alter the given checksum. Not always. You could have a content link along with a checksum served on HTTPS. The link could be a nonencrypted link -- plain HTTP or FTP, or something else. On the downside, the unencrypted connection can get easily middle-manned, on the ...


9

As written in the manual page, the /etc/networks file is to describe symbolic names for networks. With network, it is meant the network address with tailing .0 at the end. Only simple Class A, B or C networks are supported. In your example the google-dns entry is wrong. It's not a A,B or C network. It's an ip-address-hostname-relationship therefore it ...


8

The 2 methods I've seen used predominately are to use ethtool or to manually parse the contents of /sys. ethtool For example if your interface is eth0 you can query it using ethtool and then parse for the line, "Link detected". Example $ sudo ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full ...


8

I've seen (broken) smart switches going down due to nmap activity, but that was when nmapping a subnet (so ARP traffic for a lot of different endpoints). That may be the kind of problem he's thinking of. Now Intrusion Detection Systems do try and detect port scanning activity and may be configured to block the IP address of the host doing the scanning. If ...


8

To detect corruption is not entirely correct. To ascertain the integrity of the software would be a more correct usage. Normally a software is not distributed from a single server. The same software may be distributed from many servers. So when you download a particular software, the server closest to your destination is chosen as the download source to ...


7

you want tcpdump not nc, and the syntax would be tcpdump -i eth0 netcat is only for basic TCP/IP testing. tcpdump utilizes the libpcap library which allows for lowlevel interactions with packets and the likes


6

When using Network Manager the default contents of the file /etc/network/interfaces is typically this: auto lo iface lo inet loopback NOTE: That is from my Ubuntu 14.04 system, but Debian should be identical to this. Where's it come from? If you search to find out what package /etc/network/interfaces is a part of you'll find that it's not. $ dpkg -S ...


6

For tcp, just checking $?. If connection failed, $? won't be 0: $ >/dev/tcp/google.com/81 bash: connect: Network is unreachable bash: /dev/tcp/google.com/81: Network is unreachable $ echo $? 1 It will take time for bash to realize that the connection failed. You can use timeout to trigger bash: $ timeout 1 bash -c '>/dev/tcp/google.com/80' ...


6

If you're happy with netcat you can work around the file name issue by intruducing tar. This also simplifies sending multiple files at once as well as sending directories. On the sending side use: tar cf - <files> | nc <host> <port> And on the receiving side: nc -l <port> | tar x Another solution would be to use rsync or scp.


5

There is Danijel J's two options are good, but there is also a 3rd option if you have this working via the 'standard Ubuntu tool' using nmcli, which should already be installed at /usr/bin/nmcli. First, run nmcli c This will list your connections, with the first column being the SSID, and the second column being the UUID of the connection. Copy the UUID ...


5

This is as simple as it could be. You do not need any bridging. Just MASQUERADE your local network on RPi: iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE Enable forwarding of traffic: echo 1 > /proc/sys/net/ipv4/ip_forward RPi will not work as invisible bump-on-the-wire but will need a network setup between it and your private router – which ...


5

If you have this problem with every program you run, you should check your server firewall rule. Make sure that it only use NAT for external destination. Your route table make no sense if you have a wide NAT rule. After fixing firewall rule, for wget, you can use --bind-address option to chose what interface you want to use: wget ...


5

There are a few dozen versions of netcat available, but this is likely because: You have 2 entries for localhost in /etc/hosts. One for IPv4, another for IPv6. The daemon is only listening on one protocol (likely IPv4). The client is first connecting via the protocol the daemon isn't listening on, and then trying the one that it is. For example: $ grep ...


5

As someone rightly said once, Nothing is impossible in LinuxTM, I could achieve the kvm in my host with a bridged network over a wireless interface. These are the steps I followed to accomplish the same. I installed the virt-manager package to manage the installation more efficiently. I installed it as below. sudo apt-get install virt-manager Now, ...


5

Technically they should both use the same way of resolving addresses, however ping is likely not going to try resolving IPv6 addresses at all (AAAA records) and query directly A records as it's an IPv4-only tool (ping6 does IPv6 ICMP requests). A configuration issue I've seen in some load-balancing DNS servers backed by named (the same should apply no mater ...


5

1) You shouldn't manually update your resolv.conf, because all changes will be overwritten by data that your local DHCP server provides. If you want it to be static, run sudo dpkg-reconfigure resolvconf and answer "no" to dynamic updates. If you want to add new entries there, edit /etc/resolvconf/resolv.conf.d/base and run sudo resolvconf -u, it will append ...


5

Using Port 0 triggers the operating system to search for and allocate the next available port. This avoids you having to hard code a specific port or having to search for an available port. My Mint Linux system returns nc: port range not valid to nc localhost 0


5

Testing IPv4 connectivity If your network lets pings through, try pinging 8.8.8.8 (a server run by Google). if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then echo "IPv4 is up" else echo "IPv4 is down" fi Testing IP connectivity and DNS If you only want the test to succeed when DNS is also working, use a host name. if ping -q -c 1 -W 1 google.com ...


5

The original DHCP specification (RFC 2131 and 2132) defines an option (33) that allows the administrator of the DHCP service to issue static routes to the client if needed. Unfortunately, that original design is flawed these days as it assumes classful network addresses, which is rarely used. The rfc3442-classless-static-routes option allows you to use ...


5

In Linux the selection of source addresses for outgoing connections can be controlled by the routing table: ip route add 10.11.12.0/24 via 10.7.4.1 src 10.7.4.200 This is enough if you just need to use different source addresses for some fixed IP ranges. However, by combining the power of Linux netfilter (iptables) and policy routing (ip rule) you can get ...


5

You can use talk or ytalk More info: Talk ytalk Alternatively: You can use netcat, On box1: nc -l 3333 On box2: nc $IP 3333, where $IP equals the local IP address of the first system. Once you do this, in the same box (box2) , type something and press enter. Take a look on your other box. You can also choose a different port and get it opened on ...



Only top voted, non community-wiki answers of a minimum length are eligible