Showing posts with label network. Show all posts
Showing posts with label network. Show all posts

Thursday, 5 June 2014

OpenVPN: push all LAN traffic through an OpenVPN client to the other side

  1. Local variables for this post, adjust to fit your setup:
    1. OpenVPN client server IP
      1. 192.168.1.200
    2. Remote network
      1. 172.16.1.0/24
  1. Add this to the client server that is using OpenVPN to connect to the remote server:
    1. sudo iptables -A POSTROUTING -o tun0 -j MASQUERADE
    2. as root user, do
      1. echo 1 > /proc/sys/net/ipv4/ip_forward
  2. Add this to your local computer 
    1. Linux: 
      1. ip route add 172.16.1.0/24 via 192.168.1.200
    2. Mac:
      1. route -n add 172.16.1.0/24 192.168.1.200
Now, you should be able to ping from your local computer, through the client machine, and to a server in the remote network. Once that works, try ssh.

NOTE: take a look at /etc/sysctl.conf if you want the ip_forward to last through reboots of client server: net.ipv4.ip_forward=1

Tuesday, 5 November 2013

wicd: Could not connect to wicd's D-bus interface

I don't know why, she swallowed the fly.

After

  1. Wicd needs to access your computer's network cards
  2. Could not connect to wicd's D-Bus interface

Do

  1. sudo mv -v /etc/resolv.conf /etc/resolv.conf.backup
  2. sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
  3. sudo rm -v /var/lib/wicd/resolv.conf.orig
  4. sudo service wicd start
  5. yum -y install wicd-gtk
  6. wicd-gtk

Friday, 20 September 2013

Set IPs on vagrant-lxc VMs

Cross-communication is always nice.

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.define "web", primary: true do |web|
    web.vm.box = "quantal64"
    web.vm.provider :lxc do |lxc|
      lxc.customize 'network.ipv4', '10.0.3.100/32'
    end
  end

  config.vm.define "db" do |db|
    db.vm.box = "quantal64"
    db.vm.provider :lxc do |lxc|
      lxc.customize 'network.ipv4', '10.0.3.101/32'
    end
  end

end


FYI, versioning info:

vagrant -v
Vagrant 1.3.3

vagrant plugin list
vagrant-lxc (0.6.0)

Wednesday, 31 July 2013

DHCP on CLI for Ubuntu-like systems


  1. Add these lines to /etc/network/interfaces, or tweak existing eth0 lines
    1. auto eth0
    2. iface eth0 inet dhcp
  2. bring it up
    1. sudo ifup eth0
  3. bring it down
    1. sudo ifdown eth0
  4. add some stuff to /etc/dhcp/dhclient.conf
    1. interface "eth0" {
    2.     prepend domain-name-servers 192.168.100.10, 8.8.8.8, 8.8.4.4;
    3.     supersede domain-search "mydom.com", "mydom-vpc.internal";
    4. }
  5. flush on occasion
    1. ip addr flush eth0

Saturday, 29 September 2012

VLAN on Linux CLI


  1. Turn off all "Network Manager" type processes and applications
    1. Comment out /etc/network/interfaces entries even
  2. Do all commands as the root user
  3. Monitoring changes
    1. In one terminal, run this command and watch it as you execute the commands below to see what is changing
      1. sudo watch -d 'ip addr;echo =====;ip link;echo =====;ip route'
  4. Add VLAN
    1. ip link add link eth0 name eth0.20 type vlan id 20
    2. ip link set dev eth0 up
    3. ip link set dev eth0.20 up
    4. ip addr add 192.168.20.190/24 dev eth0.20
    5. ip route add default via 192.168.20.1
    6. For any other VLANs, change the "20" in the commands above to the desired VLAN, e.g.
      1. ip link add link eth0 name eth0.100 type vlan id 100
  5. Delete VLAN
    1. ip link delete eth0.20
  6. Abstract commands
    1. Create
      1. ip addr add IP/NETMASK dev INTERFACE.VID
      2. ip link set dev INTERFACE.VID up
      3. ip addr add 192.168.100.101/24 dev eth0.100
      4. ip link set dev eth0.100 up
    2. Destroy
      1. ip link set dev INTERFACE.VID down
      2. ip link set dev eth0.100 down
      3. ip link delete INTERFACE.VID
      4. ip link delete eth0.100
  7. Notes
    1. Network addr does not have to match the VLAN name
    2. VLAN name is arbitrary, you can call it "joe" if you'd like
    3. http://www.linuxjournal.com/article/7268
      1. "Trunks using the 802.1q protocol work by adding a 4-byte VLAN identifier to each frame"
      2. "When a switch receives a tagged unicast frame, it looks up the outgoing port using both the destination MAC address and the VLAN identifier"
      3. "When a broadcast frame is received, it is flooded out to all active ports participating in that VLAN"

Saturday, 8 September 2012

mac delivery mechanism


  1. your computer has a default gateway set 
    1. can figure out packet is not destined for the local network
    2. will use the MAC address of the default gateway 
  2. default gateway receives the layer-2 frame
    1. will see that the MAC address matches it's own
    2. will un-encapsulate the data link frame and 
    3. pass the data part up to the network layer
  3. at the network layer, layer 3
    1. will see that the destination IP address does not match it's own
      1. this is a packet that is supposed to be routed
    2. will look in it's routing table for the closest match
      1. which interface to send the packet out on
  4. will create a new data link frame addressed to the next hop
    1. data portion of this frame sent out the appropriate interface
  5. process will continue at each router along the way

Assume that none of the info in already cached in an ARP table on any of the machines or routers 
  1. your computer wants to send some data to a computer on network 3
    1. your computer will create an IP packet addressed to 200.0.3.2
    2. your computer will send out an ARP request for the default gateway's MAC address 
    3. on receiving the MAC address, your computer will send out the IP packet
      1. encapsulated within a data link frame that is addressed to the MAC address of router a's interface on network 1
  2. router a will receive this frame
    1. send the data portion up to the network layer 
    2. at the network layer, router a will see that the packet is not addressed to router a
    3. router a will look in it's routing table to find out where to send the packet
    4. routing table will show that network 3 is reachable via network 2
    5. routing table will also show the IP address for the next hop is 200.0.2.2
    6. router a will send out an ARP request onto network 2 asking for router b's MAC address
    7. on receiving MAC, router a will send the IP packet 
      1. encapsulated in a data link frame addressed to router b's MAC address
  3. router b receives this frame it will do the same thing that router a did
    1. will send the IP packet up to the network layer
    2. see that the packet is not addressed to router b 
    3. will then look up in it's routing table for the closest match and see that it is directly connected to network 3
      1. here isn't a next hop router to send it to. 
    4. will send out an ARP request to learn the MAC address for 200.0.3.2
    5. when MAC is received, router b will send out the IP packet
      1.  encapsulated within a data link frame that is addressed to the MAC address of the destination computer
  4. destination computer will see that the data link frame is addressed to it
    1. will pass the IP packet to the network layer. 
    2. at the network layer, the IP address will also match that of the computer
    3. the data from the IP packet will be passed up to the transport layer

Interview questions: 2020-12

Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer  Networking Layer 1 vs Layer 4 haproxy u...